{"id":33704,"date":"2013-06-06T18:25:59","date_gmt":"2013-06-06T12:55:59","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=33704"},"modified":"2026-10-13T13:42:06","modified_gmt":"2026-10-13T08:12:06","slug":"add-canonical-urls-wordpress-blogs","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/","title":{"rendered":"How to Add Canonical URLs in WordPress (Rank Math, Yoast, Code)"},"content":{"rendered":"<p>Canonical URLs tell search engines which version of a page is the main one, so duplicate versions created by tracking parameters, sorting options, print pages, HTTP\/HTTPS or www\/non-www don&#8217;t compete with each other. A canonical URL is a single line in your page&#8217;s <code>&lt;head&gt;<\/code>, and WordPress plus any good SEO plugin can add it for you. Here&#8217;s how to add canonical URLs in WordPress in 2026, how to set a custom canonical, and how to fix canonical errors in Google Search Console.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-63382\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress.webp\" alt=\"add canonical URLs in WordPress\" width=\"1200\" height=\"630\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress.webp 1200w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress-300x158.webp 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress-1024x538.webp 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress-150x79.webp 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-urls-wordpress-768x403.webp 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><strong>Quick answer:<\/strong> WordPress adds canonical URLs to posts and pages automatically. Install an SEO plugin like Rank Math, Yoast SEO or All in One SEO to add them to archives and the homepage too, and to set a custom canonical URL for any post from the plugin&#8217;s <strong>Advanced<\/strong> settings.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6af22790adc08\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6af22790adc08\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#What_is_a_canonical_URL\" >What is a canonical URL?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#How_to_add_canonical_URLs_in_WordPress\" >How to add canonical URLs in WordPress<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#1_WordPress_core_automatic\" >1. WordPress core (automatic)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#2_SEO_plugins_recommended\" >2. SEO plugins (recommended)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#3_Manual_code_no_plugin\" >3. Manual code (no plugin)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#Canonical_URL_best_practices\" >Canonical URL best practices<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#How_to_check_canonical_URLs\" >How to check canonical URLs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#Frequently_asked_questions\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#Does_WordPress_add_canonical_URLs_automatically\" >Does WordPress add canonical URLs automatically?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#Can_canonical_tags_fix_duplicate_content\" >Can canonical tags fix duplicate content?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/add-canonical-urls-wordpress-blogs\/#Should_I_use_a_canonical_or_a_301_redirect\" >Should I use a canonical or a 301 redirect?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_is_a_canonical_URL\"><\/span>What is a canonical URL?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A canonical URL is the preferred address of a page, declared with a tag like this:<\/p>\n<pre><code>&lt;link rel=\"canonical\" href=\"https:\/\/example.com\/my-post\/\" \/&gt;<\/code><\/pre>\n<p>If the same content loads at <code>example.com\/my-post\/?utm_source=newsletter<\/code> or <code>example.com\/my-post\/amp\/<\/code>, the canonical tells Google to index and rank the main URL and combine ranking signals there. Google first introduced the tag in <a href=\"https:\/\/developers.google.com\/search\/blog\/2009\/02\/specify-your-canonical\" target=\"_blank\" rel=\"noopener\">2009<\/a>, and it&#8217;s now supported by all major search engines. Note that Google treats it as a strong hint, not a command: see Google&#8217;s <a href=\"https:\/\/developers.google.com\/search\/docs\/crawling-indexing\/consolidate-duplicate-urls\" target=\"_blank\" rel=\"noopener\">guide to consolidating duplicate URLs<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_add_canonical_URLs_in_WordPress\"><\/span>How to add canonical URLs in WordPress<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_WordPress_core_automatic\"><\/span>1. WordPress core (automatic)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Since WordPress 2.9, core adds a self-referencing canonical tag to single posts and pages. It doesn&#8217;t cover the homepage, categories, tags or other archives.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_SEO_plugins_recommended\"><\/span>2. SEO plugins (recommended)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-33710\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-url-plugins.png\" alt=\"canonical URLs by SEO plugins\" width=\"393\" height=\"99\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-url-plugins.png 393w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/canonical-url-plugins-300x75.png 300w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/p>\n<p>SEO plugins replace the core tag and add canonicals across the whole site, including archives and paginated pages:<\/p>\n<ul>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/seo-by-rank-math\/\" target=\"_blank\" rel=\"noopener\">Rank Math<\/a> (which we use): edit a post, open <strong>Rank Math \u2192 Advanced<\/strong> and enter a <strong>Canonical URL<\/strong> to override the default.<\/li>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/wordpress-seo\/\" target=\"_blank\" rel=\"noopener\">Yoast SEO<\/a>: open the Yoast panel \u2192 <strong>Advanced \u2192 Canonical URL<\/strong>.<\/li>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/all-in-one-seo-pack\/\" target=\"_blank\" rel=\"noopener\">All in One SEO<\/a>: <strong>AIOSEO Settings \u2192 Advanced \u2192 Canonical URL<\/strong>.<\/li>\n<\/ul>\n<p>Use only one SEO plugin, or you may get two conflicting canonical tags.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Manual_code_no_plugin\"><\/span>3. Manual code (no plugin)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you don&#8217;t use an SEO plugin, WordPress already handles singular pages. To change the canonical for a specific case, use the <code>get_canonical_url<\/code> filter in your child theme&#8217;s <code>functions.php<\/code> rather than hard-coding a tag in <code>header.php<\/code>, which can create duplicates:<\/p>\n<pre><code>add_filter( 'get_canonical_url', function( $url, $post ) {\r\n    if ( $post-&gt;ID === 123 ) {\r\n        return 'https:\/\/example.com\/original-article\/';\r\n    }\r\n    return $url;\r\n}, 10, 2 );<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Canonical_URL_best_practices\"><\/span>Canonical URL best practices<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Use absolute HTTPS URLs<\/strong> that match your preferred domain (with or without www).<\/li>\n<li><strong>Self-reference<\/strong> every indexable page, including page 2, 3 and so on of archives. Don&#8217;t point paginated pages to page 1.<\/li>\n<li><strong>Keep signals consistent:<\/strong> internal links, your XML sitemap and redirects should all use the canonical URL.<\/li>\n<li><strong>Don&#8217;t canonicalise to a noindex or redirected page.<\/strong> Mixed signals make Google ignore your choice.<\/li>\n<li><strong>Syndicated content:<\/strong> ask partners to add a canonical pointing to your original article.<\/li>\n<\/ul>\n<p>We host WordPress in a subdirectory (<code>\/archives\/<\/code>), and early SEO plugins once generated <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2009\/04\/seo-wordpress-plugin-drops-google-pagerank\/\">wrong canonical URLs<\/a> for our homepage. Modern plugins handle subdirectory installs correctly, but it&#8217;s worth checking yours.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_check_canonical_URLs\"><\/span>How to check canonical URLs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li>View the page source (<strong>Ctrl + U<\/strong>) and search for <code>rel=\"canonical\"<\/code>. There should be exactly one.<\/li>\n<li>In <a href=\"https:\/\/search.google.com\/search-console\/about\" target=\"_blank\" rel=\"noopener\">Google Search Console<\/a>, use <strong>URL Inspection<\/strong> to compare the <strong>User-declared canonical<\/strong> with the <strong>Google-selected canonical<\/strong>.<\/li>\n<li>In <strong>Indexing \u2192 Pages<\/strong>, check reasons like &#8220;Duplicate, Google chose different canonical than user&#8221; and &#8220;Alternate page with proper canonical tag&#8221; (the latter is normal).<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Does_WordPress_add_canonical_URLs_automatically\"><\/span>Does WordPress add canonical URLs automatically?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes, for single posts and pages. For archives and the homepage, use an SEO plugin.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_canonical_tags_fix_duplicate_content\"><\/span>Can canonical tags fix duplicate content?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. They tell Google which version to index. Google doesn&#8217;t penalise ordinary duplicate content, but canonicals stop it splitting signals between URLs.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Should_I_use_a_canonical_or_a_301_redirect\"><\/span>Should I use a canonical or a 301 redirect?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Use a 301 redirect when the old URL shouldn&#8217;t be visited at all. Use a canonical when both versions need to work, such as URLs with tracking parameters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Canonical URLs tell search engines which version of a page is the main one, so duplicate versions created by tracking&#8230;<\/p>\n","protected":false},"author":4,"featured_media":63382,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[49,17],"class_list":["post-33704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/33704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=33704"}],"version-history":[{"count":3,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/33704\/revisions"}],"predecessor-version":[{"id":65485,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/33704\/revisions\/65485"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/63382"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=33704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=33704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=33704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}