You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Customize page title per plugin instance - avoid duplicated page title #5878
bugAn error in the Docusaurus core causing instability or issues with its executionfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Using plugin instance name in site title is a quite specific need.
In any case, I'd rather not apply this by default, and I think it's more a theming concern, not sure we want to add a nodejs plugin option just for this.
React Helmet already has a titleTemplate system so it's worth reusing it (already in use) instead of using our custom interpolate fn.
The way I'd solve it:
swizzle/wrap the theme DocPage component (we should rename it to something better like DocLayout, and IMHO each plugin should always have a layout comp with a consistent name)
add <Head titleTemplate={currentInstanceId === "ios" ? "%s | iOS | MySite" : "%s | Android | MySite"}/> in it
Didn't test this but it should work. I'd rather use this because this is a marginal use-case and we already have/want APIs to support that
This is not a bad idea to have such a global themeConfig but the pluginId is not necessarily a good-looking label, and we can't easily make it good looking because it's used in many places like FS paths, not allowing all kind of chars.
changed the title [-]Customize page title per plugin instance[/-][+]Customize page title per plugin instance - avoid duplicated page title[/+]on Aug 16, 2022
Upvoted. Not entirely sure what the rationale was behind the decision to create these SEO values dynamically. You want to have full control as a website owner over this aspect.
For now, the API is not perfect, but it is the most flexible: you will need to swizzle a small theme component, which makes it possible to provide your own code logic instead of dealing with a static string template.
We may provide a siteConfig option later.
I'd also like to collect feedback before implementing a new public siteConfig API. For example: are the provided callback params enough to solve most use cases?
Maybe we'll also want to deprecate siteConfig.titleDelimiter later if we have a more powerful API.
In the future, we'll likely implement an API to assign a "label" to a plugin instance. For example, you may have 2 docs plugin instance (iOS + Android). Plugin ids are used for file system paths, and are not meant to be displayed in meta title. So a plugin instance label would look cleaner to display in a title.
We also need this for docs breadcrumbs, where we'd want a breadcrumb such as Home > iOS > My iOS doc page, see related issues:
#11090 is a nice feature, but it seems the <title> and <meta name="og:title"> are still required to be the same. Would it be possible to make these different? For example, it's common for sites to specify og:title + og:site_name metadata separately, and then use <title>{title} | {siteName}</title> for the traditional title.
bugAn error in the Docusaurus core causing instability or issues with its executionfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Activity
Josh-Cena commentedon Nov 4, 2021
You can omit the
titlefield in the home page layout:And I do think there's something we can do: check if site title is equal to page title, and do not duplicate if that's the case:
https://github.com/facebook/docusaurus/blob/cbcaa52f88cb702a3712c2b4c19b02225f975ea9/packages/docusaurus-theme-common/src/utils/generalUtils.ts#L12-L14
greenpau commentedon Nov 4, 2021
@Josh-Cena , thank you! This change from defaults worked! 👍
Yes, that would be great!
Additionally, it would be nice to have
"Page Name" | "Instance Name" | "Site Title"in the case of multi-doc instance.For example, I have two pages:
Auth Portal Plugin Overview | Auth with CaddyAuthorize Plugin Overview | Auth with CaddyIt would be nice to have instance name (i.e.
AuthenticateandAuthorize) taken into account.Auth Portal Plugin Overview | Authenticate | Auth with CaddyAuthorize Plugin Overview | Authorize | Auth with CaddyJosh-Cena commentedon Nov 7, 2021
I propose this API to replace the current
titleDelimiterindocusaurus.config.js:It will leverage the existing
interpolateAPI, and you can swap out the delimiter, rearrange the components, get rid ofsiteTitleon all pages, etc.Afaik, every page belongs to a plugin, so the
pluginIDwill always be available. WhenpluginID === 'default', it will be omitted.greenpau commentedon Nov 7, 2021
@Josh-Cena , what about adding pluginTitle field?
Josh-Cena commentedon Nov 7, 2021
You mean... allowing each plugin instance to declare its own title component instead of relying on
pluginID? That sounds fine with meslorber commentedon Nov 9, 2021
Using plugin instance name in site title is a quite specific need.
In any case, I'd rather not apply this by default, and I think it's more a theming concern, not sure we want to add a nodejs plugin option just for this.
React Helmet already has a
titleTemplatesystem so it's worth reusing it (already in use) instead of using our custominterpolatefn.The way I'd solve it:
DocLayout, and IMHO each plugin should always have a layout comp with a consistent name)<Head titleTemplate={currentInstanceId === "ios" ? "%s | iOS | MySite" : "%s | Android | MySite"}/>in itDidn't test this but it should work. I'd rather use this because this is a marginal use-case and we already have/want APIs to support that
slorber commentedon Nov 9, 2021
Oh actually didn't even notice but we don't use
titleTemplatebut rather a customuseTitleFormatterhook 😅This is not a bad idea to have such a global themeConfig but the pluginId is not necessarily a good-looking label, and we can't easily make it good looking because it's used in many places like FS paths, not allowing all kind of chars.
[-]landing/home page name repeats itself[/-][+]Customize page title per plugin instance[/+]slorber commentedon May 26, 2022
Relevant discussions related to customizing site title (in particular the prefix)
#6640
#7491
elitan commentedon May 31, 2022
Another one: #7535
[-]Customize page title per plugin instance[/-][+]Customize page title per plugin instance - avoid duplicated page title[/+]anaclumos commentedon Sep 14, 2022
Would like to hear any updates on this!
Sas2k commentedon Sep 30, 2022
yeah same here (Not to NecroPost)
laureladastra commentedon Jan 25, 2023
Upvoted. Not entirely sure what the rationale was behind the decision to create these SEO values dynamically. You want to have full control as a website owner over this aspect.
jetxr commentedon Jul 1, 2023
This would be superb. Would help to avoid swizzling layouts just to change the title format.
slorber commentedon Apr 11, 2025
The use-case will be solved by #11090 in v3.8
For now, the API is not perfect, but it is the most flexible: you will need to swizzle a small theme component, which makes it possible to provide your own code logic instead of dealing with a static string template.
We may provide a
siteConfigoption later.I'd also like to collect feedback before implementing a new public
siteConfigAPI. For example: are the provided callback params enough to solve most use cases?Maybe we'll also want to deprecate
siteConfig.titleDelimiterlater if we have a more powerful API.In the future, we'll likely implement an API to assign a "label" to a plugin instance. For example, you may have 2 docs plugin instance (
iOS+Android). Plugin ids are used for file system paths, and are not meant to be displayed in meta title. So a plugin instance label would look cleaner to display in a title.We also need this for docs breadcrumbs, where we'd want a breadcrumb such as
Home > iOS > My iOS doc page, see related issues:jtbandes commentedon May 16, 2025
#11090 is a nice feature, but it seems the
<title>and<meta name="og:title">are still required to be the same. Would it be possible to make these different? For example, it's common for sites to specifyog:title+og:site_namemetadata separately, and then use<title>{title} | {siteName}</title>for the traditional title.