Skip to content

Commit c019eb1

Browse files
committed
Add noindex for untranslated sites
1 parent fb2a123 commit c019eb1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/Seo.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,18 @@ const deployedTranslations = [
2222
'zh-hans',
2323
'es',
2424
// We'll add more languages when they have enough content.
25+
// Please DO NOT edit this list without a discussion in the reactjs/react.dev repo.
26+
// It must be the same between all translations.
2527
];
2628

29+
let shouldPreventIndexing = false;
30+
if (
31+
siteConfig.languageCode !== 'en' &&
32+
!deployedTranslations.includes(siteConfig.languageCode)
33+
) {
34+
shouldPreventIndexing = true;
35+
}
36+
2737
function getDomain(languageCode: string): string {
2838
const subdomain = languageCode === 'en' ? '' : languageCode + '.';
2939
return subdomain + 'react.dev';
@@ -59,6 +69,7 @@ export const Seo = withRouter(
5969
href={canonicalUrl.replace(siteDomain, getDomain('en'))}
6070
hrefLang="x-default"
6171
/>
72+
{shouldPreventIndexing && <meta name="robots" content="noindex" />}
6273
{deployedTranslations.map((languageCode) => (
6374
<link
6475
key={'alt-' + languageCode}

0 commit comments

Comments
 (0)