Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude the canonical link from the "Relative protocol" setting to avoid SEO issues #5781

Closed
2 of 6 tasks
DahmaniAdame opened this issue Feb 24, 2023 · 1 comment · Fixed by #5807
Closed
2 of 6 tasks
Assignees
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [XS] < 1 day of estimated development time module: cloudflare priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@DahmaniAdame
Copy link
Contributor

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version 3.12.5.3
  • Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug
When the setting under the Cloudflare add-on Relative protocol is used, we change the canonical URL from:

<link rel="canonical" href="https://domain.ext/">

to

<link rel="canonical" href="//domain.ext/">

This will result Lighthouse to prompt the following recommendation when auditing the SEO part:

Document does not have a valid rel=canonicalIs not an absolute URL (//domain.ext/)

Changing the following regex found here:

$re = "/(<(script|link|img|form)([^>]*)(href|src|action)=[\"'])https?:\\/\\//i";

to exclude the canonical rel will fix the issue.

Something like the following should work:

/(<(script|link|img|form)(?!.*?\bcanonical\b)([^>]*)(href|src|action)=[\"'])https?:\\/\\//i

To Reproduce
Steps to reproduce the behavior:

  1. Enable the "Relative protocol" under Cloudflare add-on
  2. Do an SEO audit on Lighthouse
  3. See error

Expected behavior
There shouldn't be any results when the Relative protocol setting is enabled.

Screenshots
N/A

Additional context
N/A

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@piotrbak piotrbak added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting module: cloudflare priority: medium Issues which are important, but no one will go out of business. needs: grooming labels Mar 2, 2023
@CrochetFeve0251 CrochetFeve0251 self-assigned this Mar 10, 2023
@CrochetFeve0251 CrochetFeve0251 added effort: [XS] < 1 day of estimated development time and removed needs: grooming labels Mar 10, 2023
@CrochetFeve0251
Copy link
Contributor

CrochetFeve0251 commented Mar 10, 2023

Reproduce the problem

Ok

Identify the root cause

Done by @DahmaniAdame

Scope a solution

The solution from @DahmaniAdame is valid but @piotrbak do you think we should make the regex more precise with a regex checking for rel="canonical" to prevent exclusion from img that possibly have a class contaning canonical?

Estimate the effort

Effort xs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [XS] < 1 day of estimated development time module: cloudflare priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants