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
-
Is it good practice to use "SAVE $1000's" in SEO titles and Meta Descriptions?
Our company sells a product system that will permanently waterproof almost anything. We market it as a DIY system. I am working on SEO titles and descriptions. This topic came up for discussion, if using "SAVE $1000's.." would help or hurt. We are trying to create an effective call to action, but we are wondering if search engines see it as click bait. Can you
Intermediate & Advanced SEO | | tyler.louth0 -
Ranking drop for "Mobile" devices category in Google webmaster tools
Hi, Our rank dropped and we noticed it's a major drop in "Mobile" devices category, which is contributing to the overall drop. What exactly drops mobile rankings? We do not have any messages in search console. We have made few redirects and removed footer links. How these affect? Thanks,
Intermediate & Advanced SEO | | vtmoz
Satish0 -
Pagination with rel=“next” and rel=“prev”
Hi Guys, Just wondering can anyone recommend any tools or good ways to check if rel=“next” and rel=“prev” attributes have been implemented properly across a large ecommerce based site? Cheers. rel=“next” and rel=“prev”
Intermediate & Advanced SEO | | jayoliverwright0 -
Rel=canonical on pre-migration website
I have an e-commerce client that is migrating platforms. The current structure of their existing website has led to what I would believe to be mass duplicate content. They have something north of 150,000 indexed URLs. However, 143,000+ of these have query strings and the content is identical to pages without any query string. Even so, the site does pretty well from an organic stand point compared to many of its direct competitors. Here is my question: (1) I am assuming that I should go into WMT (Google/Bing) and tell both search engines to ignore query strings. (2) In a review of back links, it does appear that there is a mish mash of good incoming links both to the clean and the dirty URLs. Should I add a rel=canonical via a script to all the pages with query strings before we make our migration and allow the search engines some time to process? (3) I'm assuming I can continue to watch the indexation of the URLs, but should I also tell search engines to remove the URLs of the dirty URLs? (4) Should I do Fetch in WMT? And if so, what sequence should I do for 1-4. How long should I wait between doing the above and undertaking the migration?
Intermediate & Advanced SEO | | ExploreConsulting0 -
Pages are being dropped from index after a few days - AngularJS site serving "_escaped_fragment_"
My URL is: https://plentific.com/ Hi guys, About us: We are running an AngularJS SPA for property search.
Intermediate & Advanced SEO | | emre.kazan
Being an SPA and an entirely JavaScript application has proven to be an SEO nightmare, as you can imagine.
We are currently implementing the approach and serving an "escaped_fragment" version using PhantomJS.
Unfortunately, pre-rendering of the pages takes some time and even worse, on separate occasions the pre-rendering fails and the page appears to be empty. The problem: When I manually submit pages to Google, using the Fetch as Google tool, they get indexed and actually rank quite well for a few days and after that they just get dropped from the index.
Not getting lower in the rankings but totally dropped.
Even the Google cache returns a 404. The question: 1.) Could this be because of the whole serving an "escaped_fragment" version to the bots? (have in mind it is identical to the user visible one)? or 2.) Could this be because we are using an API to get our results leads to be considered "duplicate content" and that's why? And shouldn't this just result in lowering the SERP position instead of a drop? and 3.) Could this be a technical problem with us serving the content, or just Google does not trust sites served this way? Thank you very much! Pavel Velinov
SEO at Plentific.com1 -
Paging Question: Rel Next or Canonical?
Hi, Lets say you have a category which displays a list of 20 products and pagination of up to 10 pages. The root page has some content but when you click through the paging the content is removed leaving only the list of products. Would it be best to apply a canonical tag on the paging back to the root or apply the prev/next tags. I understand prev/next is good for say a 3 part article where each page holds unique content but how do you handle the above situation? Thanks
Intermediate & Advanced SEO | | Bondara0 -
How are PDF image alt tags and "subject" field in document properties used for search
Hello, 1. Does google use image alt tags? According to this 2011 document, the answer is no, but I have seen others claiming yes- has google since begun using alt tags for images within PDFs? http://googlewebmastercentral.blogspot.com/2011/09/pdfs-in-google-search-results.html I am trying to decide if it is worth updating existing PDFs with alt tags for images for the purpose of SEO. 2. How does Google use the "Subject" field in document properties for a PDF? Should it be used as a description field for the document, similar to a meta description? Thank you!
Intermediate & Advanced SEO | | winstoncho0 -
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