Skip to content

Navigation Menu

Sign up

Per-page social cards for Docusaurus docs and blog posts with docusaurus-plugin-myog #13114

hboon started this conversation in Plugins, Themes, Presets and Libs
Discussion options

If your Docusaurus site uses themeConfig.image, a docs page and a blog post can end up with the same card when you share them. I built MyOG.social and its Docusaurus plugin to give each page its own image while keeping the images you picked for individual posts.

Add the plugin

Use stable Docusaurus 3.10 or later in the 3.x series and Node.js 20.11.0 or newer. For a plain webpack build, use Docusaurus 3.10.1 or later.

pnpm add docusaurus-plugin-myog@0.2.0

Add this entry to your existing plugins array in docusaurus.config.ts or .js.

["docusaurus-plugin-myog", { account: "YOURACCOUNTID" }],

Copy the a= value from your install snippet and replace YOURACCOUNTID. Set url, baseUrl and trailingSlash to match your deployment. The plugin is MIT licensed. To serve the generated images, register the exact public hostname in MyOG and have credits available from a paid plan or card trial. MyOG Docusaurus setup

You can keep themeConfig.image and themeConfig.metadata. Pages without their own image use MyOG in place of the site-wide card. Remove any og:image and twitter:image tags in headTags, which can leave duplicate tags in the built HTML.

Keep a custom card on one blog post

Put your image in static/img/release-card.png. Add image to the front matter of a blog post, for example blog/2026-10-01-post-with-image.md.

---
title: Post with image
image: /img/release-card.png
---

Both image tags on that post use the supplied image. A docs page such as /docs/intro with no image of its own gets a MyOG URL.

Check the built HTML and the served images

Run pnpm run build. Open the generated HTML for each route. In the <head>, check that each image tag appears once.

  • On /docs/intro, both tags should point to the same MyOG image URL. Decode its url query parameter and compare it with the page's og:url. For url: "https://docs.example.com" and baseUrl: "/", expect https://docs.example.com/docs/intro if that route has no trailing slash.
  • On the blog post, both tags should point to release-card.png on your site. For a deployment under a subpath, the image URL includes that subpath.

The plugin writes the tags during the build. After deploying, copy each distinct image URL from the live page source and open it directly. Check for a successful HTTP response with an image content type, then look at the card to confirm it shows the intended page or artwork. If the MyOG image fails, check the registered hostname and available credits first. www.example.com and example.com need separate registrations.

If you run into an override that behaves differently, share the route type and which image tags you see in the built HTML.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /