bridgetownrb / bridgetown-seo-tag

A Bridgetown plugin to add metadata tags for search engines and social networks to better index and display your site's content.
MIT License
29 stars 8 forks source link
bridgetown bridgetown-plugin open-graph search-engine-optimization seo social-media

About Bridgetown SEO Tag

A Bridgetown plugin to add metadata tags for search engines and social networks to better index and display your site's content.

Gem Version

Installation for Bridgetown 1.2+

Run this command to add this plugin to your site's Gemfile:

$ bundle add bridgetown-seo-tag

Or simply add this line to your Gemfile:

gem 'bridgetown-seo-tag'

And then add the initializer to your configuration in config/initializers.rb:

init :"bridgetown-seo-tag"

(For Bridgetown 1.1 or earlier, read these instructions.)

Summary

Add the Liquid tag to your HTML head:

{% seo %}

Or if you wish to control your HTML <title> tag yourself:

{% seo title=false %}

You can use the seo helper in Ruby templates as well:

<%= seo %>
<!-- or -->
<%= seo title: false %>

Bridgetown SEO Tag adds the following meta tags to your site:

While you could theoretically add the necessary metadata tags yourself, Bridgetown SEO Tag provides a battle-tested template of crowdsourced best-practices.

NOTE: make sure you add your site-wide SEO Tag metadata to src/_data/site_metadata.yml, not bridgetown.config.yml

Usage

The SEO tag will use the following configuration options from bridgetown.config.yml:

The SEO tag will respect any of the following if included in your site's site_metadata.yml (and simply not include them if they're not defined):

webmaster_verifications:
  google: 1234
  bing: 1234
  alexa: 1234
  yandex: 1234
  baidu: 1234

The SEO tag will respect the following YAML front matter if included in a post, page, or document:

Note: Front matter defaults can be used for any of the above values.

Setting a default image

You can define a default image using Front Matter defaults to provide a default Twitter Card or Open Graph image to all of your documents.

Here is a very basic example, that you are encouraged to adapt to your needs:

defaults:
  - scope:
      path: ""
    values:
      image: /assets/images/default-card.png

More advanced usage information is on the Wiki here.

Testing

Contributing

  1. Fork it (https://github.com/bridgetownrb/bridgetown-seo-tag/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request