By Cache Ventures.
Metaman makes it easy to manage your meta tags on a Middleman site.
Add this line to your application's Gemfile:
gem 'middleman-metaman'
And then execute:
$ bundle
Or install it yourself as:
$ gem install middleman-metaman
Within the config.rb of the middleman project, include the line
activate :metaman, host: 'https://domain.com'
Put this in the head of your site
<%= display_meta_tags %>
You can set meta tags using multiple methods. The order of priority from lowest
to highest is defaults (data/meta_tags.yml), translations, front matter,
page specific variables set via set_meta_tags
in
a template.
The defaults file lives in data/meta_tags.yml
. You can set any meta tag you
would like. It will be converted to a hash and merged during page generation.
Nested parameters like { og: { title: 'My Title' } }
will become og:title
.
<% set_meta_tags(title: 'My Title', og: { image: 'meta-image.png' } )
Only the title
and description
can be set via Front Matter at this time.
The gem will look for translations like so. If your page is called
thank_you.html.erb
your translations should go under en > thank_you > meta > ...
Any key that includes image
in it will automatically have the host prepended
and will use the image_path
helper.
This gem currently supports generating meta tags using the
property attribute for any meta tags that start with og:
, music:
, music:
, video:
, article:
, book:
, profile:
.