sphinx-gp-opengraph¶
Alpha
Rendered output is stable. The Python API and Sphinx config value names may change without a major version bump. Pin your dependency to a specific version range in production.
OpenGraph meta-tag emission for Sphinx. The package registers every
ogp_* config value the upstream
sphinxext-opengraph
exposes and emits the same <meta> tags, with one deliberate
omission: the matplotlib-based social-card generator is not bundled.
That is why the package has zero non-Sphinx runtime dependencies.
For install, per-page overrides, Twitter-card markup, and the verbatim deprecation-warning text, see the package README. This page covers integration with gp-sphinx, the emission pipeline, the trade-offs, and the auto-generated config-value reference.
Integration with gp-sphinx¶
sphinx_gp_opengraph ships in DEFAULT_EXTENSIONS,
so projects that build through merge_sphinx_config()
load it automatically. Passing docs_url= to that function auto-derives
three of the most common config values:
Auto-derived |
Source |
|---|---|
|
|
|
|
|
|
The canonical reference for these and the other auto-derived values
lives in From docs_url. Any value passed via **overrides to
merge_sphinx_config() wins over the auto-derived default —
auto-computation runs first, overrides apply last.
Event hooks¶
config-inited → _warn_if_social_cards_used (deprecation warning)
html-page-context → html_page_context (per-page meta-tag emission)
Both hooks live in
sphinx_gp_opengraph/__init__.py.
There is no builder-inited or build-finished work — the extension
is purely a per-page transformer.
Trade-offs¶
ogp_social_cards is accepted but ignored. The upstream extension
ships a matplotlib renderer that builds per-page PNGs at
builder-inited. sphinx-gp-opengraph deliberately omits the dependency to
keep the install graph small. The config key remains registered so
existing conf.py files do not error; setting it logs a single
WARNING at config-inited directing users to the static-image
workflow documented in the README.
parallel_read_safe and parallel_write_safe are both True.
The extension never writes shared state — every emission is
self-contained inside the per-page hook — so it is safe under any
sphinx-build -j N value.
Config reference¶
Generated from app.add_config_value() registrations in
sphinx_gp_opengraph/__init__.py.
Config Value Index
Name |
Type |
Default |
Rebuild |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
ogp_site_url¶
Site base URL joined with each page’s relative path to form
og:url. Required for absolute URLs; auto-derived fromdocs_urlunder gp-sphinx.- Type:
str- Default:
''- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_canonical_url¶
Separate canonical URL used to build
og:url; falls back toogp_site_urlwhen empty.- Type:
str- Default:
''- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_description_length¶
Truncation cap (characters) applied to
og:descriptionafter extracting the first body paragraph.- Type:
int- Default:
200- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_image¶
Site-default OpenGraph image path or absolute URL. Auto-derived from
docs_urlunder gp-sphinx; per-pageog:imagefront-matter overrides.- Type:
None | str- Default:
None- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_image_alt¶
Alt text for
ogp_image. Falls back toog:site_namethenog:title;Falsesuppresses the alt tag entirely.- Type:
None | bool | str- Default:
None- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_use_first_image¶
When
Trueand no per-page override is set, use the first in-page image asog:image.- Type:
bool- Default:
False- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_type¶
Value emitted as the
og:typetag.- Type:
str- Default:
'website'- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_site_name¶
Value emitted as
og:site_name. Defaults to the Sphinxprojectname;Falsesuppresses the tag.- Type:
None | bool | str- Default:
None- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_social_cards¶
Accepted-but-ignored compatibility shim for upstream
sphinxext-opengraph. Setting any value emits a one-line WARNING atconfig-inited; provide a static PNG viaogp_imageor per-pageog:imageinstead.- Type:
None | dict- Default:
None- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_custom_meta_tags¶
Raw
<meta>tag strings appended verbatim after the structuredog:*block — the supported escape hatch for Twitter card declarations and image-dimension hints.- Type:
list | tuple- Default:
()- Registered by:
sphinx_gp_opengraph.setup()
-
ogp_enable_meta_description¶
When
True, emit a<meta name="description">mirroringog:descriptionunless the page already defines one.- Type:
bool- Default:
True- Registered by:
sphinx_gp_opengraph.setup()
Package reference¶
Copyable config snippet
extensions = [
"sphinx_gp_opengraph",
]
Package metadata
Source on GitHub: sphinx-gp-opengraph
PyPI: sphinx-gp-opengraph
Maturity:
Alpha