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
-
Should you automatically resolve URLs with extra trailing slashes added by accident?
Hi - I was just wondering whether a URL with extra trailing slashes should actuall redirect to the version without the extra trailing slashes... e.g. www.domainname.com/folder////// should automatically resolve to www.domainname.com/folder/ - what is your opinion on this?
Intermediate & Advanced SEO | | McTaggart0 -
Rel=dofollow and rel=nofollow
Hi, I found a link pointing to my client's site that looks like this: <a <span="" class="html-tag">href</a><a <span="" class="html-tag">="</a>http://www.clientsite.com" rel="dofollow" target="_blank" rel='nofollow'>Anchor text Could someone tell me if this links acts as a dofollow or as a nofollow? It's the first time I see such a link and I don't know how to handle it. Best regards, Edimar
Intermediate & Advanced SEO | | Noriel0 -
Forum generating automatically extra pages. Can I solve it with canonical?
Hey there Webmasters of the Universe. So i have this problem with my forum. The platform I am using it automatically creates extra pages for every page. For exampleIf my forum had one page called forum.com/examplethe same page you can find at forum.com/example?page=1If I set rel canonical into the second one pointing to the first one will that cause a problem for me?Thanks in advance!
Intermediate & Advanced SEO | | Angelos_Savvaidis0 -
I get warnings for overly dynamic urls, but have canonical links in place.
Hi, Seomoz gives me warnings for overly dynamic urls. This is mostly caused by a crumbtrail system. I have a canonical link in the header for all the urls I receive warnings on, should I still worry about this? Thanks!
Intermediate & Advanced SEO | | mooij0 -
Does having a trailing slash make a url different than the same url without the trailing slash?
Does having a trailing slash make a url different than the same url without the trailing slash? www.example.com/services Or www.example.com/services**/** Does Google consider these to be the same link or does Google treat them as different links?
Intermediate & Advanced SEO | | webestate0 -
OOPS!! My website links the most to me, I can't get it??
Today, I have checked Google webmaster tools to get answer of following question. Who links the most to my website? I was assumed that Google webmaster tools provide me list of external website where I have created my text links. But, I can't get it when see my own website links the most to me. (4652??) I checked my other websites which are integrated in Google webmaster tools. They also developed on same platform as well as same internal linking structure. But, I am not able to find out similar issue over there. That's why I am quite confuse with Vista Store. How can I solve it? Does it really matter? "Open Site Explorer is my favorite one and always using that to get it done. But, Google webmaster tools is also active & free so why should I not jump in to... 🙂 "
Intermediate & Advanced SEO | | CommercePundit0 -
Should I build links to the home page or a url containing the keyword?
I run an IT company and the company name does not contain the key word I am trying to rank on. I also have a bunch of pages with page rank that containing the actual keywords, for example: http://www.mycompanyname.com/tech-support/locations/brighton My target keyword is "Tech Support Brighton" My Home page is PR4 and my location based pages are PR3. My plan was to build 3 or 4 location pages for the locations we provide tech support for and target location based keyword Anchor text to these URL's e.g "Tech Support Brighton" and then for the home page build links that have the anchor text "Tech Support". Does this sound sane? Many Thanks, K
Intermediate & Advanced SEO | | SEOKeith0 -
404 Redirecting to the home page
One of my clients that is managing their own server and website recently moved servers. Which then broke their custom 404 page. Instead of fixing this or putting the site back to the old server they redirected the 404 to the home page. I've been working on getting their 404's appropriately redirected, or old urls redirection using a 301 for a month or two. I read the HTTP Status Codes best practices. It just discusses usability. What technical seo back lash can happen?
Intermediate & Advanced SEO | | triveraseo0