Seitenreport Seitenreport
Canonical in WordPress

Canonical Not Fixed in Head in WordPress

Invalid HTML can terminate the head prematurely. In WordPress, you check for core output, SEO plugin and theme head.

Core output, SEO plugin and theme head

A canonical from an HTML content block ends up in the page body. Remove this output there and use the head output provided for it.

On a single content page, check if WordPress Core, SEO plugin, and theme each output canonicals. For archives, a different logic may apply than for contributions. Do not blindly remove the core function, but first determine the leading source.

How to fix the issue in WordPress

  1. Open the HTML head of a published post or page and locate rel=canonical. Identify whether it is generated by WordPress’s rel_canonical function, the active SEO plugin or a custom theme snippet. Adding a second tag to the header will not fix an incorrect plugin value.
  2. Move canonical output from the content block into the template's head hook. Remove the old body output rather than leaving the tag in both places.

Start with one affected page or template. Check its output before applying the correction to other pages.

Example of this specific finding

Illustrative control case: A widget inserts a body element into the head before the canonical. The browser repairs the HTML and assigns subsequent elements differently.

follow-up audit in WordPress

Compare a post, a static page and an archive. The additional tag comes from a theme snippet, the change of which is first checked in a test environment.

Check both original HTML source text and parsed DOM. Fix the invalid build on the causing component and output the canonical in the valid head.

How to verify that the fix worked

In the original HTML, the link is inside the parsed head element. Also check for invalid markup that could close the head prematurely.

Check the canonical target: Compare the preferred URL with its HTTP status and indexability before changing a canonical rule.

Derogations and scope

A pure source text search for the word canonical does not reliably detect this structural error.

Related: WordPress with classic or block theme. SEO plugins and page builders are different; there is no universal menu path for all installations.

Classify the general error

Definition, system-independent causes and further correction examples: Invalid HTML may terminate the head prematurely

Configuration and test signal documentation

WordPress: Canonical edition rel_canonical

Google: Canonical Goals and Conflicting Signals

Related Canonical Errors in WordPress