What is the proper syntax for rel="canonical" ??
-
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
-
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.
-
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.
-
No problem, glad to help!
-
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!
-
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.
-
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?
-
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
Hope this helps too.
-
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...
-
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!
-
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 werecommend 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!
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
-
SEO Implications of firewalls that block "foreign connections"
Hello! A client's IT security team has firewalls on the site with GEO blocking enabled. This is to prevent foreign connections to applications as part of a contractual agreements with their own clients. Does anyone have any experience with workarounds for this? Thank you!
Intermediate & Advanced SEO | | SimpleSearch0 -
Switching from HTTP to HTTPS: 301 redirect or keep both & rel canonical?
Hey Mozzers, I'll be moving several sites from HTTP to HTTPS in the coming weeks (same brand, multiple ccTLDs). We'll start on a low traffic site and test it for 2-4 weeks to see the impact before rolling out across all 8 sites. Ideally, I'd like to simply 301 redirect the HTTP version page to the HTTPS version of the page (to get that potential SEO rankings boost). However, I'm concerned about the potential drop in rankings, links and traffic. I'm thinking of alternative ways and so instead of the 301 redirect approach, I would keep both sites live and accessible, and then add rel canonical on the HTTPS pages to point towards HTTP so that Google keeps the current pages/ links/ indexed as they are today (in this case, HTTPS is more UX than for SEO). Has anyone tried the rel canonical approach, and if so, what were the results? Do you recommend it? Also, for those who have implemented HTTPS, how long did it take for Google to index those pages over the older HTTP pages?
Intermediate & Advanced SEO | | Steven_Macdonald0 -
Nofollow "print" URLs?
Hi there, Apols for the basic question but is it considered good practice to nofollow one of one's own URLs? Basically our 'print page' command produces an identical URL in the same window but with .../?print=1 at the end. As far as I've been reading, the nofollow html attribute is, broadly speaking, only for links to external websites you don't want to vouch for or internal links to login/register pages that together with noindex, you're asking Google not to waste crawl budget on. (The print page is already noindexed so we're good there) Can anyone confirm the above from their own experience? Thanks so much!
Intermediate & Advanced SEO | | Daft.ie0 -
Something happened within the last 2 weeks on our WordPress-hosted site that created "duplicates" by counting www.company.com/example and company.com/example (without the 'www.') as separate pages. Any idea what could have happened, and how to fix it?
Our website is running through WordPress. We've been running Moz for over a month now. Only recently, within the past 2 weeks, have we been alerted to over 100 duplicate pages. It appears something happened that created a duplicate of every single page on our site; "www.company.com/example" and "company.com/example." Again, according to our MOZ, this is a recent issue. I'm almost certain that prior to a couple of weeks ago, there existed both forms of the URL that directed to the same page without be counting as a duplicate. Thanks for you help!
Intermediate & Advanced SEO | | wzimmer0 -
Linking to other peoples you tube videos related to our "How to do " articles on our website. Is there Best practices ?
Hi All, We are currently writing some "How to do" articles on our tool hire website and as there is alot of DIY related you tube videos out there, we thought It would be good to link to some of these at the bottom of our articles. From an SEO perspective, is there any do's and don'ts with regards how we should implement this. We are unable to do our videos so linking to others would be our preferred option. Does anyone know if this would give an SEO ranking benefit even though it's an outbound link to someone's video etc. thanks Pete
Intermediate & Advanced SEO | | PeteC120 -
Difference in Number of URLS in "Crawl, Sitemaps" & "Index Status" in Webmaster Tools, NORMAL?
Greetings MOZ Community: Webmaster Tools under "Index Status" shows 850 URLs indexed for our website (www.nyc-officespace-leader.com). The number of URLs indexed jumped by around 175 around June 10th, shortly after we launched a new version of our website. No new URLs were added to the site upgrade. Under Webmaster Tools under "Crawl, Site maps", it shows 637 pages submitted and 599 indexed. Prior to June 6th there was not a significant difference in the number of pages shown between the "Index Status" and "Crawl. Site Maps". Now there is a differential of 175. The 850 URLs in "Index Status" is equal to the number of URLs in the MOZ domain crawl report I ran yesterday. Since this differential developed, ranking has declined sharply. Perhaps I am hit by the new version of Panda, but Google indexing junk pages (if that is in fact happening) could have something to do with it. Is this differential between the number of URLs shown in "Index Status" and "Crawl, Sitemaps" normal? I am attaching Images of the two screens from Webmaster Tools as well as the MOZ crawl to illustrate what has occurred. My developer seems stumped by this. He has submitted a removal request for the 175 URLs to Google, but they remain in the index. Any suggestions? Thanks,
Intermediate & Advanced SEO | | Kingalan1
Alan0 -
"Jump to" Links in Google, how do you get them?
I have just seen yoast.com results in Google and noticed that nearly all the indexed pages show a "Jump to" link So instead of showing the full URL under the title tag, it shows these type of links yoast.com › SEO
Intermediate & Advanced SEO | | JohnPeters
yoast.com › Social Media
yoast.com › Analytics With the SEO, Social Media and Analytics all being clickable. How has he achieved this? And is it something to try and incorporate in my sites?0 -
Manage Ranking for " Out of Stock" pages
Hi, I own an e-commerce marketplace where the products are sold by 3rd party sellers and purchased by end users. My problem is that whenever a new product is added the search engine crawls the website and it ranks the new page on 4th page. when I start optimizing it to gain better rankings in search engines the product goes out of stock and the rankings drop to below 100. To counter that I started showing other related products on the "Out of Stock" pages but even then the rankings are dropping. Can someone help me with this problem?
Intermediate & Advanced SEO | | RuchiPardal0