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
-
Canonical - unexpected page ranking
We are getting good ranking for an unexpected page, rathewr than the one we were trying to get ranking for. Should we put a canonical on the 'unexpected page' to the page we would like to receive the ranking for - or do we risk losing the ranking? Any suggestions welcomed. Ian
Intermediate & Advanced SEO | | Substance-create0 -
Pillar pages and blog pages
Hello, I was watching this video about pillar pages https://www.youtube.com/watch?v=Db3TpDZf_to and tried to apply it to my self but find it impossible to do (but maybe I am looking at it the wrong way). Let's say I want to rank on "Normandy bike tou"r. I created a pillar page about "Normandy bike tour" what would be the topics of the subpages boosting that pillar page. I know that it should be questions people have but in the tourism industry they don't have any, they just want us to make them dream !! I though about doing more general blog pages about things such as : Places to rent a bike in Normandy or in XYZ city ? ( related to biking) Or the landing sites in Normandy ? (not related to biking) Is it the way to do it, what do you recommend ? Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
Taken a canonical off a page to let it rank with new unique content - what more can I do?
A week ago, I took a canonical off of a page that was pointing to the homepage for a very big, generic search term for my brand as we felt that it could have been harming our rankings (as it wasn't a true canonical page). A week in and our rankings for the term have dropped 7 positions out of page 1 and the page we want to rank instead is nowhere to be seen. Do I hang fire? As such a big search term, it's affecting traffic, but I don't want to make any rash decisions. Here's a bit more info: For arguments sake, let's call the search term we're going after 'Boots', with the URL where the canonical was placed of /boots. The canonical went to the root domain as we sell, well... boots. At the time, the homepage was ranking for Boots on page 1 and we wanted to change this so that the Boots page ranked for that term... all logical right? We did the following: Took off mentions of Boots from meta on the homepage and made sure it was optimised for on the boots page. Took the canonical off of /boots. Used GSC to fetch & ask Google to recrawl "/boots". Resubmitted the sitemap. Do I hang fire on running back to the safety of ranking for boots on the homepage? Do I risk keyword cannibalisation by adding the search terms back to the homepage?
Intermediate & Advanced SEO | | Kelly_Edwards0 -
Do I need to use a trailing slash to homepage in canonical and hreflang?
Currently I have a 301 redirect from
Intermediate & Advanced SEO | | lcourse
https://www.mysite.com/
to
https://www.mysite.com And in my canonical and hreflang and also insite links I use consistently https://www.mysite.com without trailing slash. Is this OK? Or do I need to add a trailing slash?0 -
Recommend Layout Page (home, categories or section, individual page)
Hello Could you please share with me your advice and recommendations on how to design a SEO layout (H1, Image, body text, etc). I need to give instructions to our website designer. I would like to see some examples. We are going to work with wordpress and visual composer. I really appreciate your help and time Andy
Intermediate & Advanced SEO | | GHSCostaRica0 -
Ecommerce: remove duplicate product pages or use rel=canonical
Say we have a white-widget that is in our white widget collection and also in our wedding widget collection. Currently, we have 3 different URLs for that product (white-widgets/white-widget and wedding-widgets/white-widget and all-widgets/white-widget).We are automatically generating a rel=canonical tag for those individual collection product pages that canonical the original product page (/all-widgets/white-widget). This guide says that is the structure Zappos uses and says "There is an elegance to this approach. However, I would re-visit it today in light of changes in the SEO world."
Intermediate & Advanced SEO | | birchlore
I noticed that Zappos, and many other shops now actually just link back to the parent product page (e.g. If I am in wedding widget section and click on the widget, I go to all-products/white-widget instead of wedding-widgets/white-widget).So my question is:Should we even have these individual product URLs or just get rid of them altogether? My original thought was that it would help SEO for search term "white wedding widget" to have a product URL wedding-widget/white-widget but we won't even be taking advantage of that by using rel=canonical anyway.0 -
Most Painless way of getting Duff Pages out of SE's Index
Hi, I've had a few issues that have been caused by our developers on our website. Basically we have a pretty complex method of automatically generating URL's and web pages on our website, and they have stuffed up the URL's at some point and managed to get 10's of thousands of duff URL's and pages indexed by the search engines. I've now got to get these pages out of the SE's indexes as painlessly as possible as I think they are causing a Panda penalty. All these URL's have an addition directory level in them called "home" which should not be there, so I have: www.mysite.com/home/page123 instead of the correct URL www.mysite.com/page123 All these are totally duff URL's with no links going to them, so I'm gaining nothing by 301 redirects, so I was wondering if there was a more painless less risky way of getting them all out the indexes (IE after the stuff up by our developers in the first place I'm wary of letting them loose on 301 redirects incase they cause another issue!) Thanks
Intermediate & Advanced SEO | | James770 -
Don't want to lose page rank, what's the best way to restructure a url other than a 301 redirect?
Currently in the process of redesigning a site. What i want to know, is what is the best way for me to restructure the url w/out it losing its value (page rank) other than a 301 redirect?
Intermediate & Advanced SEO | | marig0