Sphinx Open Graph Extension

0.13.0 · active · verified Mon Apr 13

sphinxext-opengraph is a Sphinx extension that automatically generates Open Graph Protocol (OGP) metadata for each page of your documentation. This enables rich previews when documentation links are shared on social media platforms. The current version is 0.13.0, and the project maintains an active release cadence with regular updates and support for recent Sphinx and Python versions.

Warnings

Install

Imports

Quickstart

To enable the extension, add 'sphinxext.opengraph' to the `extensions` list in your Sphinx project's `conf.py` file. The `ogp_site_url` configuration option is mandatory and must be set to the public URL of your documentation for Open Graph tags to function correctly. Optional settings like `ogp_image` and `ogp_social_cards` can further customize the generated metadata and social media previews.

# conf.py

extensions = [
    'sphinxext.opengraph',
]

# REQUIRED: Set the public URL where your documentation is hosted
ogp_site_url = "https://docs.example.com/"

# Optional: Set a default image for pages without one
ogp_image = "https://docs.example.com/_static/logo.png"

# Optional: Enable social card generation (requires matplotlib extra)
ogp_social_cards = {
    "enable": True,
    "image": "_static/social_card_logo.png", # Path relative to HTML output root
}

view raw JSON →