fix: add self-referencing canonical URLs across the site - #122
Merged
Merged
Conversation
- 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).
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds self-referencing
alternates.canonicalto 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/*):Root-relative paths resolve against the existing
metadataBase(SITE_CONFIG.primaryDomain), so all emitted URLs are absolutehttps://rustfs.com/...with the trailing slash matchingtrailingSlash: true.2. Blog tag pages (
app/blog/tag/[tag]/page.tsx): canonical/blog/tag/${tag}/added to the existinggenerateMetadata.3.
/zh/and/en/redirect shells: these are client components (JS redirects torustfs.com.cnand/respectively) and cannot export metadata, so each gets a segment-levellayout.tsxdeclaring 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 --noEmitpasses; clean build (rm -rf .next out && pnpm run build) passes; sitemap unchanged (73 URLs).index.htmlfiles carry<link rel="canonical">— the 2 without areout/404/andout/_not-found/(correct: error pages shouldn't self-canonicalize)./→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 insitemap.xml; converting them from JS redirects to server-side 301s (like the/docsfix) would be the cleaner follow-up.