How do I get rel='canonical' to eliminate the trailing slash on my home page??
-
I have been searching high and low. Please help if you can, and thank you if you spend the time reading this. I think this issue may be affecting most pages.
SUMMARY: I want to eliminate the trailing slash that is appended to my website.
SPECIFIC ISSUE: I want www.threewaystoharems.com to showing up to users and search engines without the trailing slash but try as I might it shows up like www.threewaystoharems.com/ which is the canonical link.
WHY? and I'm concerned my back-links to the link without the trailing slash will not be recognized but most people are going to backlink me without a trailing slash. I don't want to loose linkjuice from the people and the search engines not being in consensus about what my page address is.
THINGS I"VE TRIED:
(1) I've gone in my wordpress settings under permalinks and tried to specify no trailing slash. I can do this here but not for the home page.
(2) I've tried using the SEO by yoast to set the canonical page. This would work if I had a static front page, but my front page is of blog posts and so there is no advanced page settings to set the canonical tag.
(3) I'd like to just find the source code of the home page, but because it is CSS, I don't know where to find the reference. I have gone into the css files of my wordpress theme looking in header and index and everywhere else looking for a specification of what the canonical page is. I am not able to find it. I'm thinking it is actually specified in the .htaccess file.
(4) Went into cpanel file manager looking for files that contain Canonical. I only found a file called canonical.php . the only thing that seemed like it was worth changing was changing line 139 from $redirect_url = home_url('/'); to $redirect_url = home_url(''); nothing happened. I'm thinking it is actually specified in the .htaccess file.
(5) I have gone through the .htaccess file and put thes 4 lines at the top (didn't redirect or create the proper canonical link) and then at the bottom of the file (also didn't redirect or create the proper canonical link) : RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z.]+)?threewaystoharems.com$ [NC]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule .? http://www.%1threewaystoharems.com%{REQUEST_URI} [R=301,L]Please help friends.
-
Having a canonical link pointing to that same url as in the address bar has no affect as far as search engines are concern, the reason moz.com gives for doing this is that if some one scrapes your site, the canonical will point back to the original.
The whole idea of canonical tags and 301's is to do with requests, you want the all requests showing the same content to appear the same page to the search engine.
With normal pages a slash means a different request that without, and to fix it you need to create a 301 that requests again to the correct url. in the process you have lost a bit of link juice.
but when requesting the home page with or without the "/", the request is the same. there is no need to fix it.
press F12 in your browser and test it yourself using the network tab, you can see that entering the url with or without the "/" on the homepage results in the same request.
-
Thank you for your response Alan.
If what you say is true why wouldn't google webmaster tools specifically say that in their article on Canonical links? and why would high pr sites like moz.com feel the need to specify the correct link with a canonical link on their homepage. Just because the browsers read the homepage as the same does not suggest to me that it does not matter if one specifies which is the correct one. The question at hand is not whether it can be read but whether it can be back-linked to properly.
-
If you have a trailing slash, on a url like domain.com/mypage/ then that is a different url to domain.com/mypage
If you fix this with a 301 you lose a bit of link juice in the redirect.
but if you are talking about a homepage url such as domain.com and domain.com/ these are not treated as different urls, there is no redirect between them. there is no problem here, don't worry about it
-
Philip,
You are the man. That totally worked.
I do believe that google is smart enough to see them as the same, I also think it would make sense that they are trying to weed out most people that don't know what they are doing by giving priority rank to websites that backlinks that are consistent with their canonical specification. They say in their support articles that they see the trailing slash and no trailing slash sites as 2 separate sites and that webmasters will be spreading their link juice if they don't specify which one to use. It seems to logically follow that if your web users are linking to the "wrong" page, google is not going to give priority because it signifies that the developer is not properly branding his site and/or hasn't created the user experience to cause it to happen properly. Here are 2 sources where google talks about their stance on canonical links: https://support.google.com/webmasters/answer/139066?hl=en and https://support.google.com/webmasters/answer/139394?hl=en&ref_topic=2371375 . I'd like to hear any more thoughts on my hypothesis.
-
Dillon,
Thanks for the additional explanation. I do see the canonical tag in your code and see that it is being placed by Yoast's WordPress SEO plugin.
Honestly, you should not worry about the trailing slash. Google and Bing are intelligent enough to understand that .com and .com/ are the same website. You are receiving credit for your backlinks regardless of whether or not the trailing slash exists on the link.
Having said that, here's how you can remove the trailing slash if you still really want to.....
Login to your WordPress backend as an administrator and look for "Plugins" on the left menu and go to "Editor" within the plugins menu. From there, find the dropdown menu near the top right and go to "WordPress SEO". On the list of files that display on the right side, find "wordpress-seo/frontend/class-frontend.php".
In that file, use CTRL + F to find this line of code: $canonical = home_url( '/' );
Remove the / within the ' '
Click on "Update File". Refresh your homepage and you will see that the trailing slash is gone from the canonical tag. Keep in mind, this is a hack. When you update WordPress SEO, this will most likely be overwritten and you'll have to do it again.
-
Hi Philip,
Thank you for your response. I am definitely obsessing, although I'm pretty sure it is not over nothing, and, I would be happy to be proven wrong (it would save me some time) lol.
It is my understanding that a lot of browsers, like Chrome, will remove the slash from their url but just in the graphical user interface because it looks better, while in fact they reading it with the trailing slash at the end. Browser SEAMONKEY does accurately show the trailing slash. The real way to know from the coding is that the page source still shows <link rel="<a class="attribute-value">canonical</a>" href="http://www.threewaystoharems.com/" /> , when I really want it to show as <link rel="<a class="attribute-value">canonical</a>" href="http://www.threewaystoharems.com" /> (trailing slash omitted). If I were to speculate on what is really going on behind the scenes, is that google knows that most websites are going to default to using a trailing slash and most users are going to link without the trailing slash. It seems to me that google is trying to separate the SEO professionals from the amateurs by seeing these as two different sites and making the professionals have to figure out how to get the trailing slash off of their home pages in order to get their backlinks. If you notice, moz.com 's page source shows no trailing slash on their link rel="canonical" .
Am I crazy? I'm pretty sure I need to figure this out to get my backlinks to link properly.
-
Where are you seeing the trailing slash? If I go to threewaystoharems.com in my browser, there is no trailing slash. I do see a trailing slash if I do a Google search for "site:threewaystoharems.com" but that is normal. Every website will show that trailing slash.
I think you might be obsessing over a non-issue Let me know if i am misunderstanding.
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
-
Do cross domain rel canonical and original source tags have to be the same?
I have placed content on a partner site using the same content that is on my site. I want the link juice from the site and the canonical tag points back to my site. However, they are also using the original source tag as they publish a lot of news. If they have the original source tag as the page on their site and the canonical as mine, is this killing the link juice from the canonical and putting me in jeopardy of a duplicate content penalty? Google has already started indexing the page on their site with the same content.
Intermediate & Advanced SEO | | SecuritiesCE0 -
Dynamic referenced canonical pages based on IP region and link equity question
Hi all, My website uses relative URLs that has PHP to read a users IP address, and update the page's referenced canonical tag to an region specific absolute URL for ranking / search results. E.g. www.example.com/category/product - relative URL referenced for internal links / external linkbuilding If a US IP address hits this link, the URL is the same, but canonicalisation is updated in the source to reference www.example.com**/us/**category/product, so all ranking considerations are pointed to that page instead. None of these region specific pages are actually used internally within the site. This decision was done so external links / blog content would fit a user no matter where they were coming from. I'm assuming this is an issue in trying to pass link equity with Googlebot, because it is splitting the strength between different absolute canonical pages depending on what IP it's using to crawl said links (as the relative URL will dynamically alter the canonical reference which is what ranking in SERPs) Any assistance or information no matter how small would be invaluable. Thanks!
Intermediate & Advanced SEO | | MattBassos0 -
Duplicate Content Errors new website. How do you know which page to put the rel canonical tag on?
I am having problems with duplicate content. This is a new website and all the pages have the same page and domain rank, the following is an example of the homepage. How do you know which page to use the canonical tag on? http://medresourcesupply.com/index.php http://medresourcesupply.com/ Would this be the correct way to use this? Here is another example where Moz says these are duplicates. I can't figure out why because they have different url's and content. http://medresourcesupply.com/clutching_at_the_throat http://medresourcesupply.com/index.php?src=gendocs&ref=detailed_specfications &category=Main
Intermediate & Advanced SEO | | artscube.biz0 -
After Server Migration - Crawling Gets slow and Dynamic Pages wherein Content changes are not getting Updated
Hello, I have just performed doing server migration 2 days back All's well with traffic moved to new servers But somehow - it seems that w.r.t previous host that on submitting a new article - it was getting indexed in minutes. Now even after submitting page for indexing - its taking bit of time in coming to Search Engines and some pages wherein content is daily updated - despite submitting for indexing - changes are not getting reflected Site name is - http://www.mycarhelpline.com Have checked in robots, meta tags, url structure - all remains well intact. No unknown errors reports through Google webmaster Could someone advise - is it normal - due to name server and ip address change and expect to correct it automatically or am i missing something Kindly advise in . Thanks
Intermediate & Advanced SEO | | Modi0 -
Canonical URL on search result pages
Hi there, Our company sells educational videos to Nurses via subscription. I've been looking at their video search results page:
Intermediate & Advanced SEO | | 9868john
http://www.nursesfornurses.com.au/cpd When you click on a category, the URL appears like this:
http://www.nursesfornurses.com.au/cpd?view=category&cat=9&name=Acute+Surgical+Nursing
http://www.nursesfornurses.com.au/cpd?view=category&cat=6&name=Medications Would this be an instance where i'd use the canonical tag to redirect each search results page? Bearing in mind the /cpd page is under /Nursing cpd, and that /Nursing cpd is our best performing page in search engines, would it be better to refer it to the 'Nursing CPD' rather than 'CPD' page? Any advice is very welcome,
Thanks,
John0 -
Rel Alternate tag and canonical tag implementation question
Hello, I have a question about the correct way to implement the canoncial and alternate tags for a site supporting multiple languages and markets. Here's our setup. We have 3 sites, each serving a specific region, and each available in 3 languages. www.example.com : serves the US, default language is English www.example.ca : serves Canada, default language is English www.example.com.mx : serves Mexico, default language is Spanish In addition, each sites can be viewed in English, French or Spanish, by adding a language specific sub-directory prefix ( /fr , /en, /es). The implementation of the alternate tag is fairly straightforward. For the homepage, on www.example.com, it would be: -MX” href=“http://www.example.com.mx/index.html” /> -MX” href=”http://www.example.com.mx/fr/index.html“ />
Intermediate & Advanced SEO | | Amiee
-MX” href=”http://www.example.com.mx/en/index.html“ />
-US” href=”http://www.example.com/fr/index.html” />
-US” href=”http://www.example.com/es/index.html“ />
-CA” href=”http://www.example.ca/fr/index.html” />
-CA” href=”http://www.example.ca/index.html” />
-CA” href=”http://www.example.ca/es/index.html” /> My question is about the implementation of the canonical tag. Currently, each domain has its own canonical tag, as follows: rel="canonical" href="http://www.example.com/index.html"> <link rel="canonical" href="http: www.example.ca="" index.html"=""></link rel="canonical" href="http:>
<link rel="canonical" href="http: www.example.com.mx="" index.html"=""></link rel="canonical" href="http:> I am now wondering is I should set the canonical tag for all my domains to: <link rel="canonical" href="http: www.example.com="" index.html"=""></link rel="canonical" href="http:> This is what seems to be suggested on this example from the Google help center. http://support.google.com/webmasters/bin/answer.py?hl=en&answer=189077 What do you think?0 -
Culling 99% of a website's pages. Will this cause irreparable damage?
I have a large travel site that has over 140,000 pages. The problem I have is that the majority of pages are filled with dupe content. When Panda came in, our rankings were obliterated, so I am trying to isolate the unique content on the site and go forward with that. The problem is, the site has been going for over 10 years, with every man and his dog copying content from it. It seems that our travel guides have been largely left untouched and are the only unique content that I can find. We have 1000 travel guides in total. My first question is, would reducing 140,000 pages to just 1,000 ruin the site's authority in any way? The site does use internal linking within these pages, so culling them will remove thousands of internal links throughout the site. Also, am I right in saying that the link juice should now move to the more important pages with unique content, if redirects are set up correctly? And finally, how would you go about redirecting all theses pages? I will be culling a huge amount of hotel pages, would you consider redirecting all of these to the generic hotels page of the site? Thanks for your time, I know this is quite a long one, Nick
Intermediate & Advanced SEO | | Townpages0 -
Canonical category pages
A couple of years ago I used to receive a lot of traffic via my category pages but now I don't receive as much, in the past year I've modified the category pages to canonical. I have 15 genres for the category pages, other than the most recent sorting there is no sorting available for the users on the cat pages, a recent image link added can over time drop off to page 2 of the category page, for example mysite.com/cat-page1.html = 100 image links per page with numbered page navigation, number of cat pages 1-23. New image link can drop off to page 2. mysite.com/dog-page1.html = 100 image links per page with numbered page navigation, number of cat pages 1-53. New image link can drop off to page 2. mysite.com/turtle-page1.html = 100 image links per page with numbered page navigation, number of cat pages 1-2. New image link can drop off to page 2. Now on the first page (eg mysite.com/cat-page1.html) I've set this up to rel= canonical = mysite.com/cat-page1.html One thing that I have noticed is the unique popup short description tooltips that I have on the image links only appears in google for the first pages of each category page, it seems to ignore the other pages. In view of this am I right in applying canonical ref or just treating it as normal pages.? thanks
Intermediate & Advanced SEO | | Flapjack0