0.02
No commit activity in last 3 years
No release in over 3 years
OpenGraph Protocol Helper for Middleman
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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 Run tests

License

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