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
-
Magento 1.9 SEO. I have product pages with identical On Page SEO score in the 90's. Some pull up Google page 1 some won't pull up at all. I am searching for the exact title on that page.
I have a website built on Magento 1.9. There are approximately 290,000 part numbers on the site. I am sampling Google SERP results. About 20% of the keywords show up on page 1 position 5 thru 10. 80% don't show up at all. When I do a MOZ page score I get high 80's to 90's. A page score of 89 on one part # may show up on page one, An identical page score on a different part # can't be found on Google. I am searching for the exact part # in the page title. Any thoughts on what may be going on? This seems to me like a Magento SEO issue.
Intermediate & Advanced SEO | | CTOPDS0 -
Internal Clicks and CTR. Is REL=canonical better than Noindex in this case?
I currently have a search facility in a website that noindexes the search results which is ok. But when you click one of the results it takes you to a product which is noindexes as it has URL params. e.g. https://www.visitliverpool.com/accommodation/albion-guest-house-p305431?bookurl=%2Fbook-online%3Fstage%3Dunitsel%26isostartdate%3D2017-10-31%26nights%3D1%26roomReq_1_adults%3D1%26NumRoomReqs%3D1%26fuzzy%3D0%26product%3D305431 The product also exists as this which is indexed : - https://www.visitliverpool.com/accommodation/albion-guest-house-p305431 Should I canonicalise is this instance instead of no index? Does CTR apply to internal links? i.e. Does search console consider internal clicks? Are internal clicks a ranking factor?
Intermediate & Advanced SEO | | Andrew-SEO0 -
Should pages with rel="canonical" be put in a sitemap?
I am working on an ecommerce site and I am going to add different views to the category pages. The views will all have different urls so I would like to add the rel="canonical" tag to them. Should I still add these pages to the sitemap?
Intermediate & Advanced SEO | | EcommerceSite0 -
Best tips for getting a video page to rank?
We have a video for our company, located here: http://www.imageworkscreative.com/imageworks-creative-video It's an overview of our company and the services we offer. We'd like to get this page ranking, but we haven't had much luck so far. Our Youtube account does better, but I'm looking for some things we can do on or offsite to get this page to rank. Any tips would be appreciated!
Intermediate & Advanced SEO | | ScottImageWorks0 -
Role of Home Page Text
My company operates a commercial real estate web site in New York City. We are competing against brands that can spend hundreds of thousands of dollars per year on marketing and SEO. I am an independent without employees. I am trying to replace generic home page text (my web site is ww.nyc-officespace-leader.com) with more engaging language that will differentiate the site. In terms of SEO best practices, what constraints exist on home page text? Must it discuss the brand in a general way? Must it specifically describe the interior pages of a site? For new home page text, I wanted to take a practical approach and provide visitors with a checklist that would be useful for their search. The check list would be in the form 500-800 words or very practical advice, specific items they should be aware of before commencing a real estate search. No other site is taking this approach and it could save tenants time and grief. I am attaching a very rough mock up of the new text (forgive the grammar, really needs to be edited!). Is there any thing wrong with this approach? I may have stumbled on a good idea, however maybe nobody has taken this route because it is inappropriate for a home page. I would very much appreciate any comments or guidance anyone may have. Best, Alan Rosinsky 0d76Iv2
Intermediate & Advanced SEO | | Kingalan10 -
How to get around Google Removal tool not removing redirected and 404 pages? Or if you don't know the anchor text?
Hello! I can’t get squat for an answer in GWT forums. Should have brought this problem here first… The Google Removal Tool doesn't work when the original page you're trying to get recached redirects to another site. Google still reads the site as being okay, so there is no way for me to get the cache reset since I don't what text was previously on the page. For example: This: | http://0creditbalancetransfer.com/article375451_influencial_search_results_for_.htm | Redirects to this: http://abacusmortgageloans.com/GuaranteedPersonaLoanCKBK.htm?hop=duc01996 I don't even know what was on the first page. And when it redirects, I have no way of telling Google to recache the page. It's almost as if the site got deindexed, and they put in a redirect. Then there is crap like this: http://aniga.x90x.net/index.php?q=Recuperacion+Discos+Fujitsu+www.articulo.org/articulo/182/recuperacion_de_disco_duro_recuperar_datos_discos_duros_ii.html No links to my site are on there, yet Google's indexed links say that the page is linking to me. It isn't, but because I don't know HOW the page changed text-wise, I can't get the page recached. The tool also doesn't work when a page 404s. Google still reads the page as being active, but it isn't. What are my options? I literally have hundreds of such URLs. Thanks!
Intermediate & Advanced SEO | | SeanGodier0 -
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 -
Does a Single Instance of rel="nofollow" cause all instances on a page to be nofollowed?
I attended the Bruce Clay training at SMX Advanced Seattle, and he mentioned link pruning/sculpting (here's an SEOMoz article about it - http://www.seomoz.org/blog/google-says-yes-you-can-still-sculpt-pagerank-no-you-cant-do-it-with-nofollow) Now during his presentation he mentioned that if you have one page with multiple links leading to another page, and one of those links is nofollowed, it could cause all links to be nofollowed. Example: Page A has 4 links to Page B: 1:followed, 2:followed, 3:nofollowed, 4:followed The presence of a single nofollow tag would override the 3 followed links and none of them would pass link juice. Has anyone else encountered this problem, and Is there any evidence to support this? I'm thinking this would make a great experiment.
Intermediate & Advanced SEO | | brycebertola0