EPMRPP-116321 || Add custom SiteMetadata component to exclude hreflang tags and prevent canonical conflicts#1128
Conversation
WalkthroughA new Docusaurus theme component ChangesTheme Metadata Rendering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/theme/SiteMetadata/index.js`:
- Line 5: The import of PageMetadata and useThemeConfig from
'`@docusaurus/theme-common`' in src/theme/SiteMetadata/index.js violates
import/no-extraneous-dependencies because '`@docusaurus/theme-common`' (and the
related '`@docusaurus/utils-common`') are not declared as direct dependencies; fix
by adding '`@docusaurus/theme-common`' and '`@docusaurus/utils-common`' to
package.json (choose dependencies or devDependencies as appropriate) so the
import is satisfied, or alternatively add an allowlist override for
import/no-extraneous-dependencies that permits these two packages (matching the
existing allowance used for '`@docusaurus/theme-common`' in
src/components/notFoundBlock/notFoundBlock.jsx).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b8aa7838-c72b-4430-a9bf-cf44d3357da8
📒 Files selected for processing (1)
src/theme/SiteMetadata/index.js
Remove hreflang tags to fix SEO canonical conflicts
Problem
The site is deployed on both
reportportal.ioandwww.reportportal.io, both returning HTTP 200. Docusaurus generateshreflangalternate tags pointing to the non-www.URL. When a crawler visits thewww.version, it sees a conflict: the page URL does not match the canonical and hreflang URLs, and there is no self-referencing hreflang for thewww.variant.Since the site is single-language (
enonly), hreflang tags provide no SEO value and only introduce these conflicts.Solution
Swizzled the
SiteMetadataDocusaurus theme component to remove theAlternateLangHeadersfunction, which is responsible for generating<link rel="alternate" hreflang="...">tags. All other functionality (canonical URL, og:url, search metadata, custom metadata) is preserved unchanged.Summary by CodeRabbit