Avoid hashes in URLs that create separate/unique content # matchurl

Avoid hashes in URLs that create separate/unique content # matchurl

06.Oct.2021

"You probably know that using # in a URL allows you to create links that are unique to particular content on the page. For example, this blog post has no fewer than four different hash-based links pointing at it."

Hash (or URL fragment identifier) is trivially easy to implement (e.g. ). URLs with hashes can be used for navigation (e.g. Moz's blog posts use the hash to navigate you to a particular comment, like this one from my wife). Hashes can also be used like tracking parameters (e.g. randswhisky  .#  =  twitter). Using URL hashes for something other than these, such as showing unique content than what's available on the page without the hash or wholly separate pages is generally a bad idea.

"If you're sending users to one specific spot on your page, then using hashes might be helpful. For example, I had another article where I wanted readers to go directly to my response in comments: randswhisky.com/comments/#comment-9654485 . However, this isn't always useful and could actually hurt your experience."

There are many things that cause problems when using custom URLs with hashtags: They can fail silently (e.g. clickjacking ) or not at all (e.g undefined window scroll position ). Performance issues arise since browsers may request contents of new pages even if they are not visible or not even on the screen.

 

Links containing hashes load contents in very different ways than standard links so it's really hard to know what will happen until you see it with your own eyes.

"So, I'd encourage you to use this power for good and avoid creating any unnecessary hash-driven "unique content" on your page."

"So, I'd encourage you to use this power for good and avoid creating any unnecessary #hash-driven "unique content" on your page."

As a rule of thumb, don't use hashes as a way to navigate users between different pieces of content.

If there is something unique to be displayed (rather than links to navigate you elsewhere) then hashes probably shouldn't be used. URL hashes are also an easy way for hackers and others to exploit your website's content.

"The best use of the hash sign in the URL is that which helps users find their way back home."

Links containing hashes load contents in very different ways than standard links so it's really hard to know what will happen until you see it with your own eyes.  So, I'd encourage you to use this power for good and avoid creating any unnecessary #hash-driven "unique content" on your page. The best use of the hash sign in the URL is that which helps users find their way back home.

The above article is published under CC BY-SA 3.0 US, meaning this article is open source/public domain (similar to Wikipedia). You are free to share/redistribute this post using the link below:

Image credits go to Moz team for nice screenshots :)

Browser screenshot credit: Chrome via cnet.com; Firefox via mozilla.org; Opera Mini (Opera's slim web browser for mobiles and the poor internet connections) via opera.com

Article summary: Use URL hashes only if you want to navigate users elsewhere on your website or external websites, rather than show unique content on your page. If there is something unique to be displayed (rather than links to navigate you elsewhere) then hashes probably shouldn't be used. Hashes are also an easy way for hackers and others to exploit your website's content. The best use of the hash sign in the URL is that which helps users find their way back home.. Article author: Vatsal Dani , Moz's writer, living in Mumbai,

 

"Moz, you should update your blog post hrefs to use #. I've noticed that many sites link directly to the comments section at the bottom of a page, and these links can break if someone adds or removes content before it. It's much better to link directly to where the observer is located within that particular article."

 

"It's much better to link directly to where the observer is located within that particular article."

"So, if people link directly to that comments section with a hash in the url (e.g. randswhisky/comments/#comment-9654485), then it will break when it changes locations (which happens frequently). I've seen many commenters complain about the comment section not showing up and even sent two of my own posts there to make sure they weren't broken for others."

"I've seen many commenters complain about the comment section not showing up and even sent two of my own posts there to make sure they weren't broken for others."

#This is common knowledge...so avoid hashes in permalink URLs.

"So, I'd encourage you to use this power for good and avoid creating any unnecessary hash-driven "unique content" on your page."

#This is common knowledge...so don't create hashes as a way to navigate users between different pieces of content. #Just link directly to where the observer is located within that particular page, like we do in the Moz blog posts. --URLs with hashes create separate/unique content (for example: randswhisky.com/lagavulin#src=twitter). Common knowledge: Take down your website and redirect it if need be, just remove all those #'s from the URLs before uploading new files again. "It's much better to link directly to where the observer

We are social