Skip to content

Commit 7164c71

Browse files
authored
fix(seo): prevent contributors.txt from indexing and crawling (#11149)
* chore(article-footer): set rel="nofollow" on contributors.txt links * chore(cloud-function): set X-Robots-Tag header on /contributors.txt * fix(robots): disallow contributors.txt
1 parent d4c41a8 commit 7164c71

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Diff for: client/src/document/organisms/article-footer/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export function LastModified({ value, locale }) {
2929
}
3030

3131
export function Authors({ url }) {
32-
return <a href={`${url}/contributors.txt`}>MDN contributors</a>;
32+
return (
33+
<a href={`${url}/contributors.txt`} rel="nofollow">
34+
MDN contributors
35+
</a>
36+
);
3337
}
3438

3539
enum ArticleFooterView {

Diff for: cloud-function/src/headers.ts

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export function withContentResponseHeaders(
3838
xFrame: !isLiveSample,
3939
});
4040

41+
if (req.url?.endsWith("/contributors.txt")) {
42+
res.setHeader("X-Robots-Tag", "noindex, nofollow");
43+
}
44+
4145
if (req.url?.endsWith("/sitemap.xml.gz")) {
4246
res.setHeader("Content-Type", "application/xml");
4347
res.setHeader("Content-Encoding", "gzip");

Diff for: tool/build-robots-txt.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ User-agent: *
1313
Sitemap: https://developer.mozilla.org/sitemap.xml
1414
1515
Disallow: /api/
16+
Disallow: /*/contributors.txt
1617
Disallow: /*/files/
1718
Disallow: /media
1819
`;

0 commit comments

Comments
 (0)