What is the correct code to write the rel=canonical in the HTML HEAD of the page?
-
is it like:
html>
<head>
<link rel="canonical" href="http://example.com/" />
head>
<body>
...<ref>sdfdfref>
or like:
-
Yes, it's correct!
-
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. -
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!
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Canonicals
I dynamically generated pages using rewrite functions in wordpress (new-york, san-diego, san-francisco). All these pages look the same but with different content. yoast (seo wordpress plugin) was unaware of this and set canonicals up relating to the wordpress page used as the template page for the dynamic pages (City_home_page). so all these pages had the canonical https://dinnerdancecruises.com/City_Home_Page. using search console, i saw google indexed my site, looked at all these dynamically created pages (which is about 30 pages) and took them all in as duplicate pages. this happen sometime in april or may. I fixed this problem and set unique canonicals up for each dynamically created page. but now google is not crawling them for some reason. im not sure why its been months and these pages are not indexed. i thought to myself is it because these links end up on multiple pages? sort of like having "terms of agreement" link at the footer. every single page has that terms of agreement link. does google look at those links as duplicates and not index the page at all. this is where my issue lies. i need google to crawl regularly and see those pages with their new, unique canonicals and re-index them correctly. but it seems to save cpu resources, google feels once a thief always a thief. i could be wrong but this is why i need your suggestion. thank you.
On-Page Optimization | | bobperez7360950 -
Duplicate Home Page
Hi, I have a question around best practise on duplicate home pages. The /index.aspx page is showing up as a top referrer in my analytics. I have the rel=canonical tag implemented for the www.mysite.com on both pages. Do I need to 301 the /index.aspx to the mysite.com? I have a lot of links pointing to the /index.aspx (half of those are coming from the mysite.com). www.mysite.com/index.aspx www.mysite.com Many thanks Jon
On-Page Optimization | | JonRaubenheimer0 -
10 Mobile Pages. 5 Desktop Pages. Canonnical to where?
I have a mobile site with more pages than the desktop site. Normally I would just point the page equivalents to the desktop site using the rel canonnical tag. What about the 5 pages? Do I just leave them be? Thanks
On-Page Optimization | | Imajery0 -
Canonical Notice
I am curious why I receive this canonical notice even though there is a canonical for this homepage. Nq3fD.jpg
On-Page Optimization | | paumer800 -
Rel canonical Issue
I have a huge rel canonical issue showing up on my website, and I'm not sure that I fully understand why. To my knowledge, this is something that comes about when alternate urls are used to link to the same page. However, this is not a technique that I've used with my website, yet it's still raising a flag on just about every page. http://bit.ly/jYyTYN Can anyone enlighten me on what's causing this? Thanks
On-Page Optimization | | JayAdams320 -
Duplicate Page Content and Duplicate Page Title
Hi All, I'm new in SEOMoz and have some questions after I have already spend 2-3 days trying to resolve the problems identified from Crawling one of my clients websites. I get quite a lot of Duplicate Page Conntent and Page Titles warnings and trying to find a workaround through the forums and posts. I continuously get this error on most of my pages: URL: http://domain.com/benefits with the same Page but with a WWW in front URL: http://www.domain.com/benefits Any advice will be highly appreciated. Thanks, Athos
On-Page Optimization | | athosk0 -
Too Many On-Page Links
Hi All, New to SEOMoz, so thanks in advance for any answers! Looking at our Crawl Diagnostics and "Too Many On-Page Links" is first on the list. The site was build with the intention of users being able to quickly get to where they want to go with drop down menus (sub nav), so we built the navigation using bullet points/css. Yes, agreed there are too many links on each page from our navigation, main nav cats are 4 with sub nav about 40, but what is the best way to resolve the problem other then removing most of the links (from the sub nav drop down)? Could we just use the attribute rel=nofollow for the sub nav links? TIA
On-Page Optimization | | bmmedia0 -
Pages not cached
Sorry for all the questions. I have dozens of article pages that are not cached by google. How can I get them cached?
On-Page Optimization | | azguy0