Skip to content

EPMRPP-116321 || Add custom SiteMetadata component to exclude hreflang tags and prevent canonical conflicts#1128

Merged
siarheirazuvalau merged 2 commits into
developfrom
bugfix/EPMRPP-116321-disable-hreflang-generation
Jun 8, 2026
Merged

EPMRPP-116321 || Add custom SiteMetadata component to exclude hreflang tags and prevent canonical conflicts#1128
siarheirazuvalau merged 2 commits into
developfrom
bugfix/EPMRPP-116321-disable-hreflang-generation

Conversation

@siarheirazuvalau

@siarheirazuvalau siarheirazuvalau commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Remove hreflang tags to fix SEO canonical conflicts

Problem

The site is deployed on both reportportal.io and www.reportportal.io, both returning HTTP 200. Docusaurus generates hreflang alternate tags pointing to the non-www. URL. When a crawler visits the www. version, it sees a conflict: the page URL does not match the canonical and hreflang URLs, and there is no self-referencing hreflang for the www. variant.

Since the site is single-language (en only), hreflang tags provide no SEO value and only introduce these conflicts.

Solution

Swizzled the SiteMetadata Docusaurus theme component to remove the AlternateLangHeaders function, 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

  • New Features
    • Added automatic canonical URL generation computed from site settings and page pathname for improved search engine optimization
    • Implemented Open Graph and Twitter Card meta tag rendering to enhance social media sharing and previews
    • Enabled locale-specific search metadata configuration for better discoverability
    • Extended custom meta tag support through theme configuration for additional flexibility

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

A new Docusaurus theme component SiteMetadata renders document-level metadata for all pages. It computes canonical URLs from the site configuration and current route, emits Open Graph and Twitter card tags, injects optional default image metadata, includes search metadata with the current locale, and renders custom metadata entries from theme configuration.

Changes

Theme Metadata Rendering

Layer / File(s) Summary
Canonical URL infrastructure
src/theme/SiteMetadata/index.js
Imports React, Docusaurus hooks/utilities for routing and URL building. Adds useDefaultCanonicalUrl hook to derive fully-qualified canonical URLs from the current route and theme url/baseUrl/trailingSlash configuration. Adds CanonicalUrlHeaders component to select between a provided permalink or default canonical URL and render <meta property="og:url"> and <link rel="canonical"> tags.
SiteMetadata orchestration
src/theme/SiteMetadata/index.js
Implements default export SiteMetadata component that injects Twitter card meta tag and a body CSS class via Head, conditionally includes PageMetadata for a configured default image, renders canonical URL headers via CanonicalUrlHeaders, emits search metadata with the current locale using DEFAULT_SEARCH_TAG, and iterates over theme-provided metadata entries to emit additional <meta> tags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • reportportal/docs#1112: Adds per-page canonical and robots meta tags in case-study MDX heads, overlapping with this PR's theme-level canonical URL metadata rendering.

Suggested reviewers

  • pressayuliya
  • maria-hambardzumian

Poem

🐰 A meta-tag feast, so crisp and clean,
Canonical URLs now reign supreme,
With OG tags and Twitter cards in place,
Each page declares its destined space! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title references a ticket number (EPMRPP-116321) and describes the main change: adding a custom SiteMetadata component to exclude hreflang tags and prevent canonical conflicts, which aligns with the actual code changes and PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/EPMRPP-116321-disable-hreflang-generation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 00b79ce and 63c9bb2.

📒 Files selected for processing (1)
  • src/theme/SiteMetadata/index.js

Comment thread src/theme/SiteMetadata/index.js Outdated
@siarheirazuvalau siarheirazuvalau changed the title EPMRPP-116321 || Remove hreflang tags to resolve canonical conflicts EPMRPP-116321 || Add custom SiteMetadata component to exclude hreflang tags and prevent canonical conflicts Jun 8, 2026
@siarheirazuvalau siarheirazuvalau merged commit 92d5b0e into develop Jun 8, 2026
2 checks passed
@siarheirazuvalau siarheirazuvalau deleted the bugfix/EPMRPP-116321-disable-hreflang-generation branch June 8, 2026 15:24
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.

2 participants