Skip to content

Auto-generate page preview images based on page metadata #66

@choldgraf

Description

@choldgraf

Many websites automatically generate a PNG "image preview" for social media sharing that contains the page title and some other page metadata. This uses the opengraph protocol for images, and so this functionality could be a useful part of this extension.

Proposal

Add the ability to optionally auto-generate an image preview for the page based on page metadata. It would display:

  • The site title
  • The site logo
  • The page title
  • Either a site tagline, hand-written page description, or the first several paragraphs of text.

In the future, it might also be able to display things like reading time or author ID, but this isn't built into Sphinx and is probably out of scope for a first PR.

Implementation

There's a prototype of this functionality already working at this repository:

It uses matplotlib to generate a little image for each page, and then links the og:image meta tag to that preview image.

Design ideas

I don't think it'll be productive if we fall down a long design hole, but I wanted to propose this structure to see if anybody had any major concerns or preferences for a different style. It is heavily inspired by the GitHub image previews (see below):

In this case, most of the elements (including colors) could be configurable, and able to be turned off.

image

There's also a figma link here but I think I might be the only one that can edit?

Here are a few design ideas to use for inspiration:

Toggle previews

GitHub

MkDocs Material

A personal blog from Hugo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions