paint-brush
Does WordPress Canonical Redirect Prevent the "Duplicated Content" Issue?by@maciejbis
2,273 reads
2,273 reads

Does WordPress Canonical Redirect Prevent the "Duplicated Content" Issue?

by Permalink Manager ProMarch 23rd, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

If a single page can be reached through many URLs, Google will treat them as duplicates of the same page and will choose only one URL as the canonical one to be indexed. Google will either pick the URL for you or consider both URLs to be equal. This might result in a substantially lower rank in search results. Even worse, the search engine may pick the incorrect page as the original, displaying outdated content. WordPress uses the “[redirect_canonical()] function, which is intended to prevent duplicate content penalty.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Does WordPress Canonical Redirect Prevent the "Duplicated Content" Issue?
Permalink Manager Pro HackerNoon profile picture


Canonical redirect may be confusing to the average WordPress user, yet they can have a big influence on search engine optimization. This article’s goal is to provide you with all of the necessary information concerning them.


This article's main point might be summarized in one line. The primary purpose of canonical and old slug redirects is to avoid "duplicated content" issue which might hurt your SEO score.


I have found this to be the most common mistake my clients make when optimizing their websites for search engines. However, the good news is that it is easily remediable, which is why I wanted to raise awareness about it.

Can "duplicated content" harm your SEO?

Simply said, if a single page can be reached through many URLs, Google will treat them as duplicates of the same page and will choose only one URL as the canonical one to be indexed. If this occurs on your website, Google will either pick the URL for you or consider both URLs to be equal, which might result in a substantially lower rank in search results. Even worse, the search engine may pick the incorrect page as the original, displaying outdated content.

https://www.youtube.com/watch?v=8j_hxBw5B4E


Duplicate content can be a real nightmare for both visitors and search engines. Regardless of how bad it seems, this is a simple problem to solve. In essence, canonicalization is all you need to take control and tell search engines which pages you want them to crawl. You may use a meta tag with a canonical URL or a “301 redirect” or a combination of the two.


Check out Google Search Central’s article on duplicate and canonical URLs for additional details and tips.


Despite its flaws, WordPress can handle this issue quite reliably. Now we will look at one of its built-in features that aims to solve the issue of duplicate permalinks. We will not get into the specifics of WordPress permalink use, since you are likely already familiar with them.


What exactly is a “canonical redirect”?

Simply said, alternative URLs may be accessed because WordPress identifies them dynamically using so-called “rewrite rules” based on regular expressions (REGEX). The term or post will be loaded as long as the URL follows the general URL pattern and the last component (slug) matches an existing content item.


So, how does WordPress make advantage of canonical redirects? The best way to ensure that both users and search engines are forwarded to the proper page is via a server-side redirection. In order to do this, WordPress uses the “redirect_canonical()” function, which is intended to prevent duplicate content penalty by redirecting all incoming links to the canonical one.


If you want to learn more about canonical redirect, check out our website.

What is an “old slug redirect”?

Old slug redirect” works in a similar manner to canonical redirect. Old slug redirect is used to provide a fallback for old slugs. Shortly, every time you change the slug, WordPress will save its previous version as a custom field ( _wp_old_slug).


If activated, the function will check if the requested slug is linked to any post. If it is, WordPress will trigger redirect to the correct permalink.


This particular functionality is rarely used. As mentioned above WordPress saves the old slugs in wp_postmeta table using ‘_wp_old_slug’ meta key. The other problem here is that there is no easy way to list all the saved slugs that will trigger the redirect.


As if that were not bad enough, this functionality is not even described in full in the official WordPress documentation.

WordPress redirects are not always reliable

The canonical redirect functionality contains one additional, lesser-known component - the “redirect_guess_404_permalink()” function. What exactly is the purpose of this feature? When a user enters a URL that does not exist based on the precise WordPress query, it attempts to redirect the user to a similar link. In other words, it tries to “correct” the requested URL and send a visitor to the actual URL address.

Requested (incorrect) URL


Canonical (correct) URL

https://example.com/incomplete-perm/

==>

https://example.com/incomplete-permalink/


This “guess-redirect” feature is useful for both SEO and UX, but it might cause some strange behavior in certain circumstances. If you have discovered that any of your URLs are redirecting to odd URLs and articles, you should turn it off.


To do so, copy the code below and paste it into your child theme's functions.php file.


# Disable "guess 404 permalink" redirection
add_filter( 'do_redirect_guess_404_permalink', '__return_false' );

How to deactivate redirect functions?

If you utilize a custom redirection solution and do not want WordPress to get in the way, you may fully deactivate the built-in tools.


You can deactivate both “Canonical redirect” and “Old slug redirect” in Permalink Manager settings. The free version of the plugin (Permalink Manager Lite) allows for the same functionality.


If you only want to disable the canonical redirect, you might not need to use a separate permalink plugin. You may also use a code snippet to deactivate WordPress's built-in redirect functionalities:


# Disable canonical redirect completely
remove_action( 'template_redirect', 'redirect_canonical' );

# Disable "old slug" redirection
remove_action( 'template_redirect', 'wp_old_slug_redirect' );


Learn more about Permalink Manager Pro.