question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate OpenGraph metadata for social previews and cards

See original GitHub issue

Content authors can add schema.org, OpenGraph, and Twitter Cards metadata

  • Book-level metadata (defaults?)
  • Page/Chapter/Section-level metadata (overrides?)

Describe alternatives you’ve considered

is it already possible to include raw HTML? Front-matter metadata would be more user-friendly

Additional context

To complete this

This should be completed by deciding how to add support for the sphinxext-opengraph extension. This Sphinx extension will include opengraph metadata on all pages.

Two options:

  1. Natively support it via a config section like:

    opengraph:
        title:
        image:
        ...
    
  2. Document how to manually enable this via Sphinx configuration in _config.yml

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
cranmercommented, Sep 3, 2020

I couldn’t find mentions of open graph social previews in the documentation.

I just enabled this with sphinxext.opengraph and a config like this

sphinx:
  extra_extensions:
  - sphinxext.opengraph
  config:
    ogp_site_url: "https://cranmer.github.io/stats-ds-book/"
    ogp_image: "https://cranmer.github.io/stats-ds-book/_static/logo.png"
    ogp_description_length: 200

But that doesn’t provide page-level metadata.

2reactions
westurnercommented, Jan 19, 2021

https://myst-parser.readthedocs.io/en/latest/using/syntax.html#setting-html-metadata :

Setting HTML Metadata¶ The front-matter can contain the special key html_meta; a dict with data to add to the generated HTML as <meta> elements. This is equivalent to using the RST meta directive.

HTML metadata can also be added globally in the conf.py via the myst_html_meta variable, in which case it will be added to all MyST documents. for each document, the myst_html_meta dict will be updated by the document level front-matter html_meta, with the front-matter taking precedence.

  • DOC: Template/Examples of how to specify both OpenGraph and Twitter Cards metadata in <meta> tags within <head>
  • ENH: How to specify schema.org metadata once and generate OpenGraph and Twitter Cards metadata (for search indexing and social share cards)
  • ENH: how to append a script(type=application/ld+json) to e.g. doc.body that will be rendered as <script type="application/ld+json" id="abstract hypothesis premise conclusion further study">
Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenGraph - Preview Social Media Share and Generate ...
The Easiest Way to Preview and Generate Open Graph Meta Tags. Try the Free Meta Tag Generator and preview all Open Graph meta...
Read more >
Open Graph: How to create sharable social media previews
Open Graph is all about meta tags — specifically, adding meta tags to an HTML page to explicitly define pieces of standardized information....
Read more >
Open Graph - Preview or Generate Social Media Meta Tags
For SEO, use our free online og tags generator tool to preview or generate open graph meta tags for websites or blogs.
Read more >
How To Add Twitter Card and Open Graph Social Metadata to ...
There are a few tools you can use to preview how your meta tags would display on a website. The Open Graph Debugger...
Read more >
12 Essential Open Graph Meta Tags for Facebook and Twitter
Open graph meta tags provide more control over how social media sites display your links. Here's why they matter -- and how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found