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
-
Rel=Canonical Vs. 301 for blog articles
Over the last few years, my company has acquired numerous different companies -- some of which were acquired before that. Some of the products acquired were living on their previous company's parent site vs. having their own site dedicated to the product. The decision has been made that each product will have their own site moving forward. Since the product pages, blog articles and resource center landing pages (ex. whitepapers LPs) were living on the parent site, I'm struggling with the decision to 301 vs. rel=canonical those pages (with the new site being self canonicaled). I'm leaning toward take-down and 301 since rel=canonicals are simply suggestions to Google and a new domain can get all the help it can to start ranking. Are there any cons to doing so?
Intermediate & Advanced SEO | | mfcb0 -
Software "card" carousel results
Hi all! Does anyone have advice for getting a software product to appear in the card results at the top of SERPs? Example https://www.google.com/search?q=budgeting+software&rlz=1C1CHBF_enUS784US784&oq=budgeting+software&aqs=chrome..69i57j0l5.2194j0j7&sourceid=chrome&ie=UTF-8 dzTpe2B
Intermediate & Advanced SEO | | SimpleSearch0 -
When "pruning" old content, is it normal to see an drop in Domain Authority on Moz crawl report?
After reading several posts about the benefits of pruning old, irrelevant content, I went through a content audit exercise to kick off the year. The biggest category of changes so far has been to noindex + remove from sitemap a number of blog posts from 2015/2016 (which were very time-specific, i.e. software release details). I assigned many of the old posts a new canonical URL pointing to the parent category. I realize it'd be ideal to point to a more relevant/current blog post, but could this be where I've gone wrong? Another big change was to hide the old posts from the archive pages on the blog. Any advice/experience from anyone doing something similar much appreciated! Would be good to be reassured I'm on the right track and a slight drop is nothing to worry about. 🙂 If anyone is interested in having a look: https://vivaldi.com https://vivaldi.com/blog/snapshots [this is the category where changes have been made, primarily] https://vivaldi.com/blog/snapshots/keyboard-shortcut-editing/ [example of a pruned post]
Intermediate & Advanced SEO | | jonmc1 -
Indexed Pages Different when I perform a "site:Google.com" site search - why?
My client has an ecommerce website with approx. 300,000 URLs (a lot of these are parameters blocked by the spiders thru meta robots tag). There are 9,000 "true" URLs being submitted to Google Search Console, Google says they are indexing 8,000 of them. Here's the weird part - When I do a "site:website" function search in Google, it says Google is indexing 2.2 million pages on the URL, but I am unable to view past page 14 of the SERPs. It just stops showing results and I don't even get a "the next results are duplicate results" message." What is happening? Why does Google say they are indexing 2.2 million URLs, but then won't show me more than 140 pages they are indexing? Thank you so much for your help, I tried looking for the answer and I know this is the best place to ask!
Intermediate & Advanced SEO | | accpar0 -
Can adding "noindex" help with quality penalizations?
Hello Moz fellows, I have another question about content quality and Panda related penalization. I was wondering this: If I have an entire section of my site that has been penalized due to thin content, can adding "noindex,follow" to all pages belonging to that section help de-penalizing the rest of the site in the short term, while we work to improve those penalized pages, which is going to take a long time? Can that be considered a "short term solution" to improve the overall site scoring on Google index while we work to improve those penalized pages, and, once ready, we remove the "noindex" tag? I am eager to know your thoughts on this possible strategy. Thank you in advance to everyone!
Intermediate & Advanced SEO | | fablau0 -
Canonical Related question
I have a site where we have search and result pages, google webmaster tool was giving me duplicate content error for page 1 / 2 / 3 etc etc so i have added canonical on these pages like http://www.business2sell.com/businesses/california/ Is this is correct way of using canonical ?
Intermediate & Advanced SEO | | manish_khanna0 -
Has important is it to set "priority" and "frequency" in sitemaps?
Has anyone ever done any testing on setting "priority' and "frequency" in their sitemaps? What was the result? Does specifying priority or frequency help quite a bit?
Intermediate & Advanced SEO | | nicole.healthline2 -
How do you rank in the "brands for:" section in Google's search results ?
There's a "brands for:" section that appears above the first organic listing for certain search queries. For example, if you search for "dedicated servers" in Google, you will see that a "brands for:" appears. How do you get listed there? Thanks, Brian
Intermediate & Advanced SEO | | InMotionHosting0