diff --git a/src/components/Layout/Page.tsx b/src/components/Layout/Page.tsx index fb771f901..04876bab3 100644 --- a/src/components/Layout/Page.tsx +++ b/src/components/Layout/Page.tsx @@ -28,7 +28,12 @@ interface PageProps { children: React.ReactNode; toc: Array; routeTree: RouteItem; - meta: {title?: string; canary?: boolean; description?: string}; + meta: { + title?: string; + titleForTitleTag?: string; + canary?: boolean; + description?: string; + }; section: 'learn' | 'reference' | 'community' | 'blog' | 'home' | 'unknown'; } @@ -107,6 +112,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) { <> ; @@ -36,6 +37,7 @@ function getDomain(languageCode: string): string { export const Seo = withRouter( ({ title, + titleForTitleTag, image = '/images/og-default.png', router, children, @@ -46,7 +48,9 @@ export const Seo = withRouter( const canonicalUrl = `https://${siteDomain}${ router.asPath.split(/[\?\#]/)[0] }`; - const pageTitle = isHomePage ? title : title + ' – React'; + // Allow setting a different title for Google results + const pageTitle = + (titleForTitleTag ?? title) + (isHomePage ? '' : ' – React'); // Twitter's meta parser is not very good. const twitterTitle = pageTitle.replace(/[<>]/g, ''); let description = isHomePage diff --git a/src/content/reference/react/use-client.md b/src/content/reference/react/use-client.md index f0510415b..b1ba1d7ae 100644 --- a/src/content/reference/react/use-client.md +++ b/src/content/reference/react/use-client.md @@ -1,5 +1,6 @@ --- title: "'use client'" +titleForTitleTag: "'use client' directive" canary: true --- diff --git a/src/content/reference/react/use-server.md b/src/content/reference/react/use-server.md index 4acea191c..cc271669a 100644 --- a/src/content/reference/react/use-server.md +++ b/src/content/reference/react/use-server.md @@ -1,5 +1,6 @@ --- title: "'use server'" +titleForTitleTag: "'use server' directive" canary: true ---