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. On-Page / Site Optimization
    4. What is the correct code to write the rel=canonical in the HTML HEAD of the page?

    What is the correct code to write the rel=canonical in the HTML HEAD of the page?

    On-Page / Site Optimization
    6 4 122
    • 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.
    • dubraverd
      dubraverd last edited by

      is it like:

      html>

      <head>

      <link rel="canonical" href="http://example.com/" />

      head>

      <body>

      ...<ref>sdfdfref>

      or like:

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

        The first example would be the correct way to apply the code to your homepage. The second example you would want to apply to a specific page that the /wordpress/seo-plugin directs to. Just keep in mind that most of your pages are going to have a unique canonical tag, which can become overwhelming to apply manually. I see you referenced WordPress above, if your site is being hosted on WordPress, I would recommend installing the Yoast plug-in. Yoast will take care of all canonicals for you.

        Hope this helps!

        dubraverd 1 Reply Last reply Reply Quote 0
        • GastonRiera
          GastonRiera last edited by

          Hi there,

          In the first example, there is a mistake: the ending sign finish like this ' /> ' and it should finish like any other tag in HTML: like this ' > ' (in both, without the ' ' )

          And what Chris says is right, the first points to the homepage and the second one to a specific page.

          Best Luck.
          GR.

          dubraverd 1 Reply Last reply Reply Quote 2
          • dubraverd
            dubraverd @Chris_Devona last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • dubraverd
              dubraverd @GastonRiera last edited by

              This post is deleted!
              Martijn_Scheijbeler 1 Reply Last reply Reply Quote 0
              • Martijn_Scheijbeler
                Martijn_Scheijbeler @dubraverd last edited by

                Yes, it's correct!

                1 Reply Last reply Reply Quote 2
                • 1 / 1
                • First post
                  Last post
                • The correct way to rel=canonical
                  KevnJr
                  KevnJr
                  1
                  3
                  124

                • Should you 301, 302, or rel=canonical private pages?
                  StephanSolomonidis
                  StephanSolomonidis
                  0
                  5
                  539

                • Can you use the canonical tag and rel=next and rel=prev on category pages.
                  Palmbourne
                  Palmbourne
                  0
                  4
                  760

                • What is the Impact of Canonical to a Canonical Page?
                  Andy.Drinkwater
                  Andy.Drinkwater
                  0
                  4
                  58

                • 301 to Intermediate Page then Rel=Canonical from Intermediate to target page
                  Dr-Pete
                  Dr-Pete
                  0
                  3
                  250

                • Rel canonical tag back to the same page the tag is on?
                  Dr-Pete
                  Dr-Pete
                  0
                  7
                  7.1k

                • Which pages should use rel="canonical" links?
                  Highland
                  Highland
                  0
                  7
                  340

                • Rel="canonical" on home page?
                  Dr-Pete
                  Dr-Pete
                  0
                  5
                  2.4k

                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