middleman-og is an extension for the Middleman static site generator that adds Open Graph helper.
Ruby Gherkin HTML
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
features
fixtures
lib
spec
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile.mm3
Gemfile.mm4
LICENSE.md
README.md
Rakefile
middleman-ogp.gemspec

README.md

Middleman-OGP

middleman-ogp is an extension for the Middleman static site generator that adds OpenGraph Protocol support.

Configuration

In your config.rb

activate :ogp do |ogp|
  #
  # register namespace with default options
  #
  ogp.namespaces = {
    fb: data.ogp.fb,
    # from data/ogp/fb.yml
    og: data.ogp.og
    # from data/ogp/og.yml
  }
  ogp.base_url = 'http://mysite.tld/'
end

In your project's root directory

Create data/ogp/fb.yml and data/ogp/og.yml files.

Example:

image:
  '': http://mydomain.tld/path/to/fbimage.png
  secure_url: https://secure.mydomain.tld/path/to/fbimage.png
  type: image/png
  width: 400
  height: 300
locale:
  '': en_us

In your layout

source/layout.slim

html
  head
    meta charset="utf-8"
    title= data.page.title
    - ogp_tags do|name, value|
      meta property=name content=value

  body
    .container
      = yield

In your page source

Page data overrides default options. (deep merge).

---
ogp:
  og:
    description: 'This is my fixture Middleman site.'
    image:
      '': http://mydomain.tld/path/to/fbimage.png
      secure_url: https://secure.mydomain.tld/path/to/fbimage.png
      type: image/png
      width: 400
      height: 300
    locale:
      '': en_us
      alternate:
        - ja_jp
        - zh_tw
  fb:
    description: 'This is my fixture Middleman site.'
    image:
      '': http://mydomain.tld/path/to/fbimage.png
      secure_url: https://secure.mydomain.tld/path/to/fbimage.png
      type: image/png
      width: 400
      height: 300
---

Hello
=====

This is the __content__

Blog Support

middleman-ogp supports adding article properties like article:published_time, article:tag automatically for middleman-blog articles.

Set ogp.blog to true in your configuration. (Defaults to false)

activate :ogp do |ogp|
  #
  # register namespace with default options
  #
  ogp.namespaces = {
    fb: data.ogp.fb,
    # from data/ogp/fb.yml
    og: data.ogp.og
    # from data/ogp/og.yml
  }
  ogp.blog = true
end

Build & Dependency Status

Gem Version Build Status Dependency Status Code Quality

License

Copyright (c) 2014 Atsushi Nagase. MIT Licensed, see LICENSE for details.