Canonical URLs in Yoast SEO
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 you do want to change them, each piece of content has a canonical field where you can enter the absolute canonical URL.
- Log in to your WordPress website.
When you're logged in, you will be in your 'Dashboard'.
- 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.
- For posts and pages, scroll down to the Yoast SEO metabox and click on the 'Advanced' gear icon to enter the full canonical URL including http/s and www or non-www.
For taxonomies or other paginated pages, scroll down to the Yoast SEO settings section.
- Update the post, page or taxonomy.
Canonical elements for paginated archives
A common misconception is that the canonical on a paginated page should always point to page 1 in the series. This is not the case. When you do that, you run the risk of search engines not indexing links that appear on page 2, 3 etc. of your archives. This would cause older articles to drop out of the search results entirely.
Of course, you can change the canonical element of a category, tag or other taxonomy archives to point at another page. To do this, go into the taxonomies settings and set the canonical:
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.