SEO gem for your Middleman apps.
Based on meta-tags Rails gem.
Add this line to your application's Gemfile:
gem 'middleman-meta-tags'
And then execute:
$ bundle
Or install it yourself as:
$ gem install middleman-meta-tags
Edit config.rb
and add:
activate :meta_tags
set_meta_tags title: 'Relevant title'
title 'Relevant title'
set_meta_tags description: 'Powerful website full of best practices and keywords'
description 'Powerful website full of best practices and keywords'
set_meta_tags keywords: %w(some seo keywords).join(', ')
keywords %w(some seo keywords).join(', ')
Into your <head></head>
tag:
display_meta_tags site: 'My Awesome Website'
By default, there is a |
as separator between title and website name.
You can modify it by adding: separator: '»'
If you want to enable auto meta tagging, put this in you <head></head>
tag:
auto_display_meta_tags
This will look inside of data/site.yml
file to find any site wide defaults.
Then it looks the page meta data to attempt to display the following keys:
- MM
site
=> METAtitle
- MM
title
=> METAtitle
- MM
description
=> METAdescription
- MM
keywords
=> METAkeywords
- MM
twitter_card
(defaults tosummary_large_image
) => METAtwitter:card
- MM
twitter_author
=> METAtwitter:creator
- MM
description
=> METAtwitter:description
- MM
pull_image
=> METAtwitter:image:src
- MM
publisher_twitter
=> METAtwitter:site
- MM
title
=> METAtwitter:title
- MM
description
=> METAog:description
- MM
pull_image
=> METAog:image
- MM
site
=> METAog:site_name
- MM
title
=> METAog:title
In addition, if you want to customize meta tags by each page's frontmatter, you
can add customize_by_frontmatter: true
in data/site.yml
. The priority would
be set_meta_tags > frontmatter > site wide defaults.
Create a helper method inside of your config.rb, like so
helper do
def my_tags
set_meta_tags key => value
end
end
And add it to the layouts and views that you need.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request