Use the metadata Docusaurus already has
Documentation files normally include a title, description, sidebar label, and slug. Those are enough to generate a useful card. Add optional ogTemplate and ogAccent fields only when the page needs a different design.
Render before the Docusaurus build
Use a Node script to scan Markdown and MDX frontmatter, render a card for entries whose tracked fields changed, and save the output under static/img/og. The image frontmatter value then points to a normal static asset copied into the deployment.
Add the script before docusaurus build in the package scripts. Keep the API key in the CI environment and out of customFields, which may be exposed to client-side code.
Set a global fallback, then override pages
Docusaurus supports a site-level social card through themeConfig.image. Use that for utility pages, while documentation and blog frontmatter supply the generated page-specific asset. This ensures every route has a usable fallback without making every low-value page consume a render.
Use specialized cards for releases
The changelog and announce templates are better fits for version launches than a generic article card. Map release-note files to changelog, pass the version as a tag, and include the two or three changes a reader should recognize at a glance. Documentation guides can continue using the article template.
Animated templates can produce GIF, WebP, or MP4 output, but use motion deliberately. Discord and Slack can display animated unfurls; other platforms receive or cache still imagery differently. A settled PNG remains the safest general-purpose default for documentation.
Inspect the production route
Theme customization and plugins can override metadata after the build. Check the deployed page with the OG image inspector rather than assuming the frontmatter won. Verify both a documentation page and a blog post, since Docusaurus processes them through different plugins.
Related guides: Next.js, Hugo, and Satori alternative.