Skip to content

etaymor/middleman-meta-tags

 
 

Repository files navigation

Middleman-MetaTags

middleman-meta-tags is an extension for the Middleman static site generator that adds easy meta tags in a similar opinionated way as Dmytro Shteflyuk's excellent meta-tags for Rails.

This is a work-in-progress. I wanted to familiarize myself with Cucumber for testing and also extending a library like Middleman. Also, meta-tags is a great convenience for Rails and it'd be nice to have it for other frameworks too!

Installation

If you're just getting started, install the middleman gem and generate a new project:

gem install middleman
middleman init MY_PROJECT

If you already have a Middleman project: Add gem "middleman-meta-tags" to your Gemfile and run bundle install.

Configuration

activate :meta_tags

Usage

The extension adds new helpers for your templates.

Setting up your layout

In your my_layout.erb, you might do something like this:

  <head>
    <%= display_meta_tags site: 'Hello world!', description: 'This is the descriptive field' %>
  </head>

  ...

Which will render this:

    <head>
        <title>Hello world!</title>
        <meta name="description" content="This is the descriptive field" />
    </head>

    ... 

Configuring tags by page-by-page basis

In a page wrapped by my_layout.erb, you can override the site-wide tags using the title helper like so:

---
title: This is my title
---

<h1><%=title current_page.data.title %></h1>
<html>
    <head>
        <title>This is my title</title>
        <meta name="description" content="This is the descriptive field" />
    </head>
    <body>
        <h1>This is my title</h1>
    </body>

</html>   

How to Run Cucumber Tests

  1. Checkout Repository: git clone https://github.com/middleman/middleman-meta-tags.git
  2. Install Bundler: gem install bundler
  3. Run bundle install inside the project root to install the gem dependencies.
  4. Run test cases: bundle exec rake test

Donate

Click here to lend your support to Middleman

License

Copyright (c) 2013-2014 Dan Nguyen. MIT Licensed

About

Meta and SEO tag helpers for Middleman

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published