Allscreenshots Docs
Tools

MkDocs plugin

Automatically generate OG images for your MkDocs documentation

MkDocs plugin

Automatically generate dynamic OpenGraph images for every page in your MkDocs documentation. When someone shares a link to your docs, they see a live screenshot of that page.

Install: pip install mkdocs-allscreenshots-og-screenshot

Installation

Install the plugin

pip install mkdocs-allscreenshots-og-screenshot

Requires Python 3.8 or higher.

Add to mkdocs.yml

site_url: https://yourdomain.com

plugins:
  - search
  - allscreenshots-og-screenshot

Verify your domain

Go to the Social images page in your dashboard and verify your documentation domain.

That's it. Every page in your documentation now has a unique OG image.

How it works

The plugin adds an og:image meta tag to each page:

<meta property="og:image" content="https://og.allscreenshots.com?url=https://yourdomain.com/page/" />

When someone shares a link on social media:

  1. The platform requests the OG image URL
  2. Allscreenshots captures a screenshot of that page
  3. The screenshot is cached for fast subsequent requests
  4. Cache hits are free and don't count toward your quota

Configuration

OptionDefaultDescription
screenshot_base_urlhttps://og.allscreenshots.comScreenshot API endpoint
site_urlMkDocs site_urlOverride the site URL used in OG image URLs

Custom configuration

plugins:
  - allscreenshots-og-screenshot:
      screenshot_base_url: https://og.allscreenshots.com
      site_url: https://docs.example.com

Requirements

Example

Given this MkDocs structure:

docs/
├── index.md
├── getting-started.md
└── api/
    └── reference.md

The plugin generates these OG images:

PageOG Image URL
/https://og.allscreenshots.com?url=https://yourdomain.com/
/getting-started/https://og.allscreenshots.com?url=https://yourdomain.com/getting-started/
/api/reference/https://og.allscreenshots.com?url=https://yourdomain.com/api/reference/

Troubleshooting

Images not generating

Ensure your domain is verified in the dashboard. Unverified domains will receive an error response.

Wrong site URL

If your OG images point to the wrong URL, set the site_url option explicitly:

plugins:
  - allscreenshots-og-screenshot:
      site_url: https://docs.example.com

Local development

OG images only work for publicly accessible URLs. During local development, the images will show an error. This is expected—the images will work once deployed.

Source code

The plugin is open source and available on PyPI.

# Install for development
pip install -e .

MIT License.

On this page