Welcome to WebmasterWorld Guest from 35.153.135.60

Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Different content based on the anchor in the URL

     
6:08 pm on Jul 2, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Nov 13, 2016
posts:1011
votes: 244


Hi

I noticed that a site like "Can I Use" is redirecting all its pages to its homepage, and adding an anchor.

For example:

https://caniuse.com/css-table

becomes

https://caniuse.com/#feat=css-table

So I was wondering how Google Bot is handling this. Does it take in consideration the anchor in an URL ? Meaning that if the same URL(I don't know how to call it) has different anchors, each one will be processed as a different page?

Or is it a trick to by pass the Brand safety of Adsense?

Or a way to consolidate links , with all links pointing to the same page (from an URL point of view)


Mod's note: Needed to delinked urls to disable auto-linking, both to make the urls visible, and also... in this case... because the WebmasterWorld redirection script disables the hash-character, so the links wouldn't work. Copy and paste them into your address bar to see what they do.

[edited by: Robert_Charlton at 4:26 am (utc) on Jul 3, 2018]
[edit reason] Disabled auto-link so examples are visible. [/edit]

3:05 am on July 3, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11715
votes: 211


they are using a javascript redirect.
(i.e. using location.href)
iirc google normally treats these as 301 redirects and indexes the ultimate url.
although i've seen sitelinks to document fragment identifiers ("anchors"), i've never heard of google indexing document fragment identifiers for main search results.
this is probably one of those cases where "normally" doesn't apply and google is ignoring the redirected url and treating the js redirect as a 302.
this is probably also a case where the authority of the site in question motivated google to figure it out with an "abnormal" treatment.

another deficiency in this implementation is that google won't see the redirect until the page is rendered and the javascript is executed vs a 301 which is seen in the status code of the response.

the lessons here are:
- don't rely on javascript redirects since you don't know when google will treat it as a 301 vs a 302
- don't redirect urls for actual pages to a fragment identifier unless your content is actually an identified fragment on that page - e.g. when several thin pages are combined into one. (note that "redirect everything to the home page" normally is treated like a "soft 404")
- don't expect that your poor choices in technical implementation will necessarily be rescued by google's algorithm.
11:02 am on July 3, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Nov 13, 2016
posts:1011
votes: 244


this is probably also a case where the authority of the site in question motivated google to figure it out with an "abnormal" treatment.

Wish I be authoritative...
5:47 pm on July 3, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15705
votes: 812


don't rely on javascript redirects since ...
... since you then have to come up with alternative methods for users with scripting turned off. On a site like caniuse, you might reasonably expect this to be a slightly higher proportion of users than on some randomly chosen site.
6:15 pm on July 3, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Apr 1, 2016
posts:2624
votes: 774


they are using a javascript redirect.

They are not redirecting anything, the site is a SPA (Single Page App) using XHR(AJAX) to add/remove content from the page. The # hash or often referred to as "hashbang" is used to direct the server using (AJAX) to the correct content once the shell page is loaded. Do not use this method it is obsolete.

If you are using a SPA pattern or AJAX I strongly recommend you watch this video from Google I/O 2018 , which explains the best way to structure URL's and get your content crawled by Google when using Javascript.

[youtube.com...]

Hash and Hashbang are discussed at 7:22 in the video, but I strongly recommend watching the whole video.
7:33 pm on July 3, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15705
votes: 812


They are not redirecting anything
If the URL visible in the browser's address bar is different from the URL the visitor initially typed in, there has been a redirect.

The # hash or often referred to as "hashbang"
Is there a typo somewhere in this thread? The hashbang is !# (or is it #! ?) while the # alone is a fragment link.

Back to one of the questions posed in OP: if Google didn't pay attention to # in URLs, they would never be able to send searchers to places other than the top of a page. Which they have been doing for many years.
12:37 am on July 4, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Apr 1, 2016
posts:2624
votes: 774


Is there a typo somewhere in this thread?

Yes a hashbang is #!, but the simple hash is often referred to as hashbang despite there being no "bang" "!". It is a common misnomer.

if Google didn't pay attention to # in URLs, they would never be able to send searchers to places other than the top of a page. Which they have been doing for many years.

Yes they were doing this in the past but have official stopped, according to the video linked above. Some sites may still benefit from it, but it is certainly not a pattern you would want to use today.

If the URL visible in the browser's address bar is different from the URL the visitor initially typed in, there has been a redirect.

No, not true. A user event such as a button click or scroll can trigger js that can be used to re-write the url , add and remove content from the page. Just because the url changes does not mean there has been a redirect. In the "can I use case" there is no redirect (at least when I use the site), now you may be going to the site with js disabled, in which case you may be seeing a redirect.
1:01 am on July 4, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11715
votes: 211


Yes a hashbang is #!, but the simple hash is often referred to as hashbang despite there being no "bang" "!". It is a common misnomer.

the hash symbol has been used as a "document fragment identifier" since TB-L's first RFC on the subject in June 1994:
HASH FOR FRAGMENT IDENTIFIERS

The hash ("#", ASCII 23 hex) character is reserved as a delimiter
to separate the URI of an object from a fragment identifier .

source: https://www.ietf.org/rfc/rfc1630.txt

the hashbang fragment was a google proposal in 2009 that was withdrawn in 2015:
https://en.wikipedia.org/wiki/Fragment_identifier#Proposals