Skip to content

Commit 6a16f6e

Browse files
authored
Merge pull request #11965 from ethereum/canonical-trailing-slash
fix: remove trailing slash from canonical url
2 parents 22d6537 + 0ca297f commit 6a16f6e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/PageMetadata.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ const PageMetadata: React.FC<IProps> = ({
4444
const path = asPath.replace(/[\?\#].*/, "")
4545
const slug = path.split("/")
4646

47-
/* Set canonical URL w/ language path to avoid duplicate content */
48-
/* e.g. set ethereum.org/about/ to ethereum.org/en/about/ */
49-
const url = new URL(join(locale === DEFAULT_LOCALE ? "" : locale!, path), SITE_URL).href
47+
/**
48+
* Set canonical URL w/ language path to avoid duplicate content
49+
* If English, remove language path
50+
* Remove trailing slash
51+
* @example ethereum.org/about/ -> ethereum.org/about
52+
* @example ethereum.org/pt-br/web3/ -> ethereum.org/pt-br/web3
53+
*/
54+
const url = new URL(join(locale === DEFAULT_LOCALE ? "" : locale!, path), SITE_URL).href.replace(/\/$/, "")
5055
const canonical = canonicalUrl || url
5156

5257
/* Set fallback ogImage based on path */

0 commit comments

Comments
 (0)