ngs / middleman-ogp

middleman-og is an extension for the Middleman static site generator that adds Open Graph helper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

middleman-og is an extension for the Middleman static site generator that adds Open Graph helper.

License:MIT License


Languages

Language:Ruby 68.2%Language:Gherkin 23.9%Language:HTML 7.9%