Skip to content

fix: add self-referencing canonical URLs across the site - #122

Merged
majinghe merged 1 commit into
rustfs:mainfrom
majinghe:feat/add-canonical-urls
Sep 22, 2026
Merged

majinghe merged 1 commit into
rustfs:mainfrom
majinghe:feat/add-canonical-urls

Conversation

@majinghe

Copy link
Copy Markdown
Contributor

Summary

Adds self-referencing alternates.canonical to every content page. Before this PR, only the blog pages had canonical URLs — the homepage, all product/download/legal pages served no canonical at all, leaving URL-variant deduplication entirely to Google.

What changed

1. 17 static pages — canonical added (app/page.tsx, about, contact, contact-us, cookie-policy, demo, download + download/cli + download/server, erasure-code-calculator, pricing, privacy-policy, 5 × product/*):

alternates: { canonical: "/about/" },

Root-relative paths resolve against the existing metadataBase (SITE_CONFIG.primaryDomain), so all emitted URLs are absolute https://rustfs.com/... with the trailing slash matching trailingSlash: true.

2. Blog tag pages (app/blog/tag/[tag]/page.tsx): canonical /blog/tag/${tag}/ added to the existing generateMetadata.

3. /zh/ and /en/ redirect shells: these are client components (JS redirects to rustfs.com.cn and / respectively) and cannot export metadata, so each gets a segment-level layout.tsx declaring its redirect target as canonical — /zh/https://rustfs.com.cn/, /en/https://rustfs.com/. This aligns each URL with the existing hreflang cluster (zh-CN → rustfs.com.cn) instead of leaving duplicate-language signals unresolved.

4. rustfs-config-generator: existing canonical/og:url lacked the trailing slash, canonicalizing to a URL form that 308-redirects; both now use /rustfs-config-generator/.

Verification

  • npx tsc --noEmit passes; clean build (rm -rf .next out && pnpm run build) passes; sitemap unchanged (73 URLs).
  • Canonical coverage measured over built HTML: 73 of 75 index.html files carry <link rel="canonical"> — the 2 without are out/404/ and out/_not-found/ (correct: error pages shouldn't self-canonicalize).
  • Spot checks:
    • /https://rustfs.com/
    • /about/https://rustfs.com/about/
    • /blog/tag/ai/https://rustfs.com/blog/tag/ai/
    • /zh/https://rustfs.com.cn
    • /en/https://rustfs.com/

Notes

/zh/ and /en/ remain listed in sitemap.xml; converting them from JS redirects to server-side 301s (like the /docs fix) would be the cleaner follow-up.

- Add alternates.canonical to the 17 static pages missing it (homepage,
  about, pricing, contact, download, products, legal pages); root-relative
  paths resolve against the existing metadataBase with trailing slashes
  matching trailingSlash: true
- Add canonical to blog tag pages via generateMetadata
- /zh/ and /en/ are client-side redirect shells and cannot export
  metadata; add segment layouts declaring their redirect targets as
  canonical (rustfs.com.cn and /), consistent with the hreflang cluster
- Fix rustfs-config-generator canonical/og:url to include the trailing
  slash so they match the served URL form

Verified: tsc passes, clean build passes, 73/75 built pages carry
canonical (404 and _not-found intentionally excluded).
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@majinghe is attempting to deploy a commit to the overtrue's projects Team on Vercel.

A member of the Team first needs to authorize it.

@majinghe
majinghe merged commit 37d0601 into rustfs:main Sep 22, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant