Skip to content

Commit

Permalink
fix(seo): prevent contributors.txt from indexing and crawling (#11149)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
caugner authored May 27, 2024
1 parent d4c41a8 commit 7164c71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/document/organisms/article-footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export function LastModified({ value, locale }) {
}

export function Authors({ url }) {
return <a href={`${url}/contributors.txt`}>MDN contributors</a>;
return (
<a href={`${url}/contributors.txt`} rel="nofollow">
MDN contributors
</a>
);
}

enum ArticleFooterView {
Expand Down
4 changes: 4 additions & 0 deletions cloud-function/src/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export function withContentResponseHeaders(
xFrame: !isLiveSample,
});

if (req.url?.endsWith("/contributors.txt")) {
res.setHeader("X-Robots-Tag", "noindex, nofollow");
}

if (req.url?.endsWith("/sitemap.xml.gz")) {
res.setHeader("Content-Type", "application/xml");
res.setHeader("Content-Encoding", "gzip");
Expand Down
1 change: 1 addition & 0 deletions tool/build-robots-txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ User-agent: *
Sitemap: https://developer.mozilla.org/sitemap.xml
Disallow: /api/
Disallow: /*/contributors.txt
Disallow: /*/files/
Disallow: /media
`;
Expand Down

0 comments on commit 7164c71

Please sign in to comment.