The project is in a healthy, maintained state
A Jekyll generator plugin that reads the image: frontmatter field on posts and pages, builds an absolute URL, and injects it as og_image for use in your <head> template.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 5.0

Runtime

>= 4.0
 Project Readme

jekyll-opengraph-image

A Jekyll generator plugin that automatically builds og:image meta tag URLs from a post or page's image: frontmatter field — no theme-specific code required.

Installation

Add to your site's Gemfile:

gem "jekyll-opengraph-image"

Then add to _config.yml:

plugins:
  - jekyll-opengraph-image

Run bundle install.

Usage

In your <head> template

{% if page.og_image %}
<meta property="og:image" content="{{ page.og_image }}" />
{% endif %}

In your frontmatter

---
title: My Post
image: /images/my-post-hero.jpg
---

The plugin reads image:, combines it with your site.url and site.baseurl, and injects the result as page.og_image.

If image: is already an absolute URL (starts with http:// or https://), it is used as-is — useful for CDN-hosted assets.

Configuration

Fallback default image

Set a site-wide default og:image for posts/pages that have no image: frontmatter:

opengraph_image:
  default: /images/default-og.jpg

If a page has no image: and no default is configured, page.og_image is nil and the {% if page.og_image %} guard in your template suppresses the tag cleanly.

How it works

The generator runs at priority :low after all other generators. For each post and page it:

  1. Reads page.image from frontmatter.
  2. Falls back to site.opengraph_image.default if page.image is absent.
  3. Skips the document if neither is present.
  4. If the resolved value is already an absolute URL, uses it unchanged.
  5. Otherwise constructs: site.url + site.baseurl + /image/path.
  6. Writes the result to page.og_image.

Edge cases handled

Scenario Behaviour
image is a relative path Prepended with site.url + site.baseurl
image starts with https:// Used as-is
baseurl is nil or empty Treated as empty string
image has leading/trailing whitespace Stripped
No image + no default og_image not set; template guard suppresses the tag

Requirements

  • Jekyll >= 4.0
  • Ruby >= 2.7

License

MIT © Jason Chance 2025