feat: add canonical url meta tag for docs pages#469
feat: add canonical url meta tag for docs pages#469TaranaKhanna wants to merge 1 commit intov0-2from
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Dynamic Route Canonical URLs src/app/api-reference/[[...slug]]/page.tsx, src/app/developing/[[...slug]]/page.tsx, src/app/guide/[[...slug]]/page.tsx, src/app/platform/[[...slug]]/page.tsx, src/app/self-hosting/[[...slug]]/page.tsx, src/app/site-policy/[[...slug]]/page.tsx |
Added alternates.canonical field to generateMetadata return value, constructing canonical URL from slug parameters to prevent duplicate content issues. |
Root Metadata Configuration src/app/layout.tsx |
Added metadataBase property to the metadata object with URL https://docs.logchimp.codecarrot.net as the base for relative canonical URLs. |
Estimated code review effort
🎯 1 (Trivial) | ⏱️ ~3 minutes
Possibly related PRs
- feat: re-structure docs #401: Implements the initial
generateMetadatafunctions for dynamic route pages that are being extended with canonical URL support in this PR.
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'feat: add canonical url meta tag for docs pages' accurately describes the main change: adding canonical URL meta tags to documentation pages across multiple route files. |
| Merge Conflict Detection | ✅ Passed | ✅ No merge conflicts detected when merging into v0-2 |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feat/add-canonical-url-meta-tag
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/app/platform/`[[...slug]]/page.tsx:
- Around line 44-46: The alternates.canonical value currently builds
`/platform/${params.slug?.join("/") ?? ""}` which yields a trailing slash when
params.slug is undefined; update the logic in the page component so canonical is
`/platform` for the index and `/platform/<joined-slug>` for subpages (e.g., use
a conditional on params.slug or trim the final slash) — apply the same change to
the other five page files that use the same pattern; target the
alternates.canonical assignment and the params.slug usage to make this change.
| alternates: { | ||
| canonical: `/platform/${params.slug?.join("/") ?? ""}`, | ||
| }, |
There was a problem hiding this comment.
Trailing slash on index pages.
When params.slug is undefined (the index route), this produces /platform/ (with a trailing slash), whereas sub-pages get /platform/setup (no trailing slash). This inconsistency can cause search engines to treat them as different URLs.
Consider trimming the trailing slash:
Proposed fix
alternates: {
- canonical: `/platform/${params.slug?.join("/") ?? ""}`,
+ canonical: params.slug ? `/platform/${params.slug.join("/")}` : "/platform",
},The same pattern applies to all six page files in this PR.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| alternates: { | |
| canonical: `/platform/${params.slug?.join("/") ?? ""}`, | |
| }, | |
| alternates: { | |
| canonical: params.slug ? `/platform/${params.slug.join("/")}` : "/platform", | |
| }, |
🤖 Prompt for AI Agents
In `@src/app/platform/`[[...slug]]/page.tsx around lines 44 - 46, The
alternates.canonical value currently builds `/platform/${params.slug?.join("/")
?? ""}` which yields a trailing slash when params.slug is undefined; update the
logic in the page component so canonical is `/platform` for the index and
`/platform/<joined-slug>` for subpages (e.g., use a conditional on params.slug
or trim the final slash) — apply the same change to the other five page files
that use the same pattern; target the alternates.canonical assignment and the
params.slug usage to make this change.
|
I have read the CLA Document and I hereby sign the CLA |
|
Ready for review. |
fixes: issue #430
Summary by CodeRabbit
Release Notes
Chores