The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Intermediate & Advanced SEO
    4. What is the proper syntax for rel="canonical" ??

    What is the proper syntax for rel="canonical" ??

    Intermediate & Advanced SEO
    11 3 11.2k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • danatanseo
      danatanseo last edited by

      I believe the proper syntax is like this [taken from the SEOMoz homepage]:

      However,

      one of the sites I am working on has all of their canonical tags set up like this:

      I should clarify, not all of their canonicals are identical to this one, they simply use this naming convention, which appears to be relative URLs instead of absolute.

      Doesn't the entire URL need to be in the tag?  If that is correct, can you also provide me with an explanation that I can give to management please? They hate it when I say "Because I said so!" LOL

      1 Reply Last reply Reply Quote 0
      • GeorgeAndrews
        GeorgeAndrews last edited by

        Hello Dana,

        I suggest reading this over: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394

        Midway down the page, Google states:

        Can the link be relative or absolute?

        rel="canonical" can be used with relative or absolute links, but we

        recommend using absolute links to minimize potential confusion or

        difficulties. If your document specifies a base link, any relative links

        will be relative to that base link.

        Hope this helps!

        danatanseo 1 Reply Last reply Reply Quote 2
        • danatanseo
          danatanseo @GeorgeAndrews last edited by

          Thanks George. Can you help me with what this means on a large site "

          If your document specifies a base link, any relative links

          will be relative to that base link."  ?  Does "document" refer to the entire site, or a single Web page?  Thanks!

          GeorgeAndrews danatanseo 6 Replies Last reply Reply Quote 0
          • GeorgeAndrews
            GeorgeAndrews @danatanseo last edited by

            Document refers to the single web page you are placing the canonical link on.

            The base link is referring to the URL you can provide as the href property for the base tag. The base tag can be included in the head of your HTML document.

            Example base link:

            <base href="http://www.ccisolutions.com/">

            If you choose to use the example base link above and this relative URL:

            Your canonical link will end up referring to “http://www.ccisolutions.com/page1.html”.

            Here is a second example, this time using a new base link which includes the products directory:

            <base href="http://www.ccisolutions.com/products/">

            If you choose to use this new base link and the following relative URL:

            Your canonical link will end up referring to “http://www.ccisolutions.com/products/page1.html”.

            If you choose to use this new base link and this relative URL:

            Your canonical link will actually refer to one-level-up from your base link or “http://www.ccisolutions.com/page1.html”. I'm not sure if you're familiar with the syntax "../" (dot dot slash), but it means to go up one level from the current directory.

            The use of base links for canonical linking might be useful for a CMS where the content is generally dynamically created. It might be good to sit down with your developers and discuss which tactic would be best for the site in question.

            I am including a link to this SEOmoz blog post in case it is also of help.

            Edit: expanded on the explanations...

            1 Reply Last reply Reply Quote 2
            • GeorgeAndrews
              GeorgeAndrews @danatanseo last edited by

              Also just to clarify, when you state they are using "relative" URLs, are you talking about "www.ccisolutions.com/page1.html" vs. "http://www.ccisoultions.com/page1.html"?

              If this is true, then both versions are absolute URLs. A relative URL is different. Here are a few examples of relative URLs:

              page1.html

              /products/page1.html

              ../products/page1.html

              ../images/image1.jpg

              /images/image1.jpg

              image1.jpg

              Each of the above are "relative links". Absolute links look like the following and don't necessarily need the "http://":

              www.ccisolutions.com/products/page1.html

              http://www.ccisolutions.com/products/page1.html

              www.ccisolutions.com/images/image1.jpg

              http://www.ccisolutions.com/images/image1.jpg

              Hope this helps too.

              1 Reply Last reply Reply Quote 2
              • danatanseo
                danatanseo @danatanseo last edited by

                Thanks so very much George for your thorough answer. This is exactly what I needed know, and it makes it possible for me to explain it to the CEO. It appears we have a confusing mixture of absolute and relative URLs, that need to be sorted out. I think sticking with the absolutes will makes it much easier.

                While we have this on the home page:

                This is an example of a category page canonical tag:

                Would I be correct is saying that there is a problem here because the actual URL of the page is

                http://www.ccisolutions.com/StoreFront/category/wireless-microphones

                So if we are going to use the relative URL in our canonical tag, it should be:

                Is that correct?

                1 Reply Last reply Reply Quote 0
                • GeorgeAndrews
                  GeorgeAndrews @danatanseo last edited by

                  Yes, you are correct. But only if you have a base link in the document:

                  <base href="http://www.ccisolutions.com/">

                  This is a very good example for why you may want to stick to Absolute URLs. With an absolute URL you only need to know the actual URL of the page:

                  Hopefully I'm not adding even more to the fire, but now might be a good time to change "StoreFront" to "storefront" all lowercase. I think lowercase URLs are better if you can use them.

                  1 Reply Last reply Reply Quote 1
                  • danatanseo
                    danatanseo @danatanseo last edited by

                    Agreed. I think if we can change the Storefront to storefront without having to employ any kinds of redirects it would be great. Otherwise, the site is so old, that it may not matter.

                    Along those lines, we recently had the opportunity to remove /Storefront from the URL string. We chose not to because the site is 10 years old and didn't want to risk losing any page or domain authority by having a whole bunch of 301 redirects.

                    Certainly interested to know your take from the viewpoint of someone who knows code. Thanks George!

                    1 Reply Last reply Reply Quote 0
                    • GeorgeAndrews
                      GeorgeAndrews @danatanseo last edited by

                      No problem, glad to help!

                      1 Reply Last reply Reply Quote 0
                      • Dr-Pete
                        Dr-Pete last edited by

                        Endorsing George for the full thread. Technically, Google does allow relative URLs, but I've heard of some odd issues, so I think it's better to use full URLs. Your home-page version isn't really either an absolute or relative URL - you really should have the "http://" (protocol) in that URL. If you're being nitpicky, that's an improper URL, and Google could end up interpreting it as something like:

                        http://www.ccisolutions.com/www.ccisolutions.com

                        Now, odds are, they won't, but with these tags it's really best to do it by the book.

                        danatanseo 1 Reply Last reply Reply Quote 2
                        • danatanseo
                          danatanseo @Dr-Pete last edited by

                          Thanks Dr. Pete! An you know what? You are absolutely right. Google has interpreted the canonical just that way and it's been in our GWT reports forever and no one could figure out where they were coming from.

                          Thank you, thank you, thank you (in my Gomer Pyle voice, of course!)

                          Wow, it's amazing how fixing one thing can sometimes take you down a whole nother road and fix something else at the same time. I just can't thank both you and George enough.

                          Kudos to George on a great answer.

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          • Syntax: 'canonical' vs "canonical" (Apostrophes or Quotes) does it matter?
                            Alick300
                            Alick300
                            0
                            2
                            77

                          • Should pages with rel="canonical" be put in a sitemap?
                            RyanPurkey
                            RyanPurkey
                            0
                            11
                            2.1k

                          • What is the difference between link rel="canonical" and meta name="canonical"?
                            Ideas-Money-Art
                            Ideas-Money-Art
                            0
                            3
                            1.3k

                          • Is it ok to add rel=CANONICAL into the desktop version on top of the rel="alternate" Tag (Mobile vs Desktop version)
                            Ideas-Money-Art
                            Ideas-Money-Art
                            0
                            3
                            172

                          • Bad use of the Rel="canonical" tag
                            Brian-H
                            Brian-H
                            0
                            4
                            554

                          • Rel="canonical" questions?
                            DoRM
                            DoRM
                            0
                            13
                            656

                          • Meta name="canonical" content="uRL" usage instead of link rel
                            Ideas-Money-Art
                            Ideas-Money-Art
                            0
                            10
                            4.7k

                          • Trailing slash and rel="canonical"
                            BethA
                            BethA
                            0
                            8
                            6.8k

                          Get started with Moz Pro!

                          Unlock the power of advanced SEO tools and data-driven insights.

                          Start my free trial
                          Products
                          • Moz Pro
                          • Moz Local
                          • Moz API
                          • Moz Data
                          • STAT
                          • Product Updates
                          Moz Solutions
                          • SMB Solutions
                          • Agency Solutions
                          • Enterprise Solutions
                          • Digital Marketers
                          Free SEO Tools
                          • Domain Authority Checker
                          • Link Explorer
                          • Keyword Explorer
                          • Competitive Research
                          • Brand Authority Checker
                          • Local Citation Checker
                          • MozBar Extension
                          • MozCast
                          Resources
                          • Blog
                          • SEO Learning Center
                          • Help Hub
                          • Beginner's Guide to SEO
                          • How-to Guides
                          • Moz Academy
                          • API Docs
                          About Moz
                          • About
                          • Team
                          • Careers
                          • Contact
                          Why Moz
                          • Case Studies
                          • Testimonials
                          Get Involved
                          • Become an Affiliate
                          • MozCon
                          • Webinars
                          • Practical Marketer Series
                          • MozPod
                          Connect with us

                          Contact the Help team

                          Join our newsletter
                          Moz logo
                          © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                          • Accessibility
                          • Terms of Use
                          • Privacy