sphinxext-opengraph
sphinxext-opengraph copied to clipboard
Copy other metadata systematically
So, in my site my pages have consistent metadata with fields like title. I'd love to have these automatically also populate the og:title field. Any suggestions on how this could be done?
My pages today look like the following (with MyST)
---
title: How I Conduct an Interview
og:title: How I Conduct an Interview
date: 2023-01-06
...
How are you injecting titles or other metadata into pages conditionally? The regular default for OpenGraph (being the first header on the page) for titles solves most cases, as the first header is usually identical to the title of the page.
I put the following in my template, mostly to help avoid duplication
{%- if meta is mapping and "title" in meta %}
<h1> {{ meta.get("title") }} </h1>
{%- endif %}