Canonical URLs in Yoast SEO

Table of contents

How to Change the Canonical
Canonical Elements For Paginated Archives
Developer Code
Troubleshooting

Yoast SEO (free or premium) adds canonical URLs to your WordPress install for all content that is marked for indexing by search engines. It does this automatically and in 99.9% of cases you don’t have to change anything about them. If, however, you do with to chance the canonical, follow the steps below.

How to change the canonical


Each piece of content has a canonical field where you can enter the absolute canonical URL. Follow these steps to make the changes.

  1. Log in to your WordPress website.

    When you’re logged in, you will be in your ‘Dashboard’.

  2. Edit the post, page, or taxonomy.

    On the left-hand side, you will see a menu that allows you to navigate to your posts, pages, and other content. Navigate to the individual item to edit the content settings.

  3. For posts and pages, scroll down to the Yoast SEO metabox. Under the ‘SEO’ tab, click to expand the ‘Advanced’ section.

    Yoast SEO metabox with the advanced section highlighted

  4. Enter the full canonical URL, including http/s and www or non-www, in the ‘Canonical URL’ field.

    Yoast SEO metabox with the canonical section highlighted

  5. Update the post, page or taxonomy.

Canonical elements for paginated archives

In Yoast SEO we also add tags to paginated archive series. Those are the rel="next" and rel="prev" tags, that give search engines more information about your content. If the tags don’t work on your paginated content, read this article.

Developer code

If you want, you can also filter the output of the canonical programmatically. To do this you can use the wpseo_canonical filter. If you return false on that, no canonical will be output. Some examples can be found here.

If you are not sure how or where to enter the filter you may wish to use a Yoast Partner who can help.

Troubleshooting

I do not have a canonical tag

In some cases you may not see a canonical tag being outputted on a page. If this is the case check to see if the page has a noindex tag. If it does, that is the reason why. We do not output a canonical tag if the page is marked as noindex. To resolve the issue mark the pages as index.

This guide explains more about how to remove noindex tags: How do I Noindex URLs? You may need to check in several spots.