Docusaurus V2 - Use page title for og:title on docs

Viewed 588

At the moment my og:title is using the title defined in the config not the current doc title.

---
id: my_id
title: My Title ** I want it to pull in this
sidebar_label: My Title
---

I've changed my file from .md to .mdx and tried to define this in the <Head> component but this didn't work.

import Head from '@docusaurus/Head';

<Head>
  <meta property="og:title" content="My custom title" />
</Head>

Any help would be really appreciated.

Thanks.

2 Answers

For now I've used swizzle to override the DocItem component.

yarn docusaurus swizzle @docusaurus/theme-classic DocItem
Related