Jump to content
iwato

Using the Hash Tag as a Query String

Recommended Posts

PROBLEM:  Please examine carefully to following two code block and focus specifically on the use of the # tag to as a key-value identifier.

CASE ONE:

<a href="https://www.grammarcaptive.com/overview.html#pk_campaign=Letter+No.+53">Learn more!</a>

In the above example only a hash tag is used.  In the following example both the hash tag and a query parameter are used.

CASE TWO:

<a href="https://www.grammarcaptive.com/overview.html?q=test#pk_campaign=Letter+No.+53&pk_kwd=Order+Now%21">Order now!</a>

Although I can pretty well guess the meaning of the first example, I am completely baffled by the use of the second.

QUESTION ONE:  In the first example, does the # tag simply replace the query tag?  In other words ?pk_campaign means the same as #pk_campaign.

QUESTION TWO: If the # tag simply replaces the ? tag can you also write?

#pk_campaign=Letter+No.+53&pk_kwd=Order+Now%21

QUESTION THREE:  How does one interpret Case Two?

Roddy

 

 

Share this post


Link to post
Share on other sites

Everything following the # and the # itself is called a hash. The hash part of a URL is never sent to the server and is only seen by the browser. Its original purpose was to jump to a specific section on the page, but in this example and in many other common applications it's used to provide information that Javascript can read.

In the case that there's both a query string and a hash, it's usually because the query string has information that the server needs while the hash has information for the browser.

The hash cannot replace the query string. The hash does not naturally have key=value pairs like the query string does, it just contains an arbitrary string which can contain & and = characters. People write Javascript code to parse them and treat them as if they were query strings, but they are not.

Share this post


Link to post
Share on other sites

OK.   Please respond to the following question with this scenario in mind: either of the above two links is included in an email that is sent to a subscriber from the grammarcaptive.com domain.  The information appended to the link is to be used by a third-party application located on the domain's server.

QUESTION ONE:  Would it be to safe to conclude that, when told that one has the option of using a query string or hash to send the information, the email must contain javascript that would parse the hash and send the information in an HTTP request separate from that generated upon clicking the link.

QUESTION TWO:  If the answer to Question One is in the affirmative.  What would compel the developer  of the third-party application to make such an option possible?

Roddy

 

 

 

Share this post


Link to post
Share on other sites

The Javascript to parse the hash would be on the page that the e-mail links to, not in the e-mail itself. E-mails cannot have Javascript in them. It is not a good idea to use the hash to send data, the hash should generally only be used as it was originally intended, as an anchor to a specific part of the page.

When you're using a third party application you have to play by their rules. If their application isn't compatible with your software then you will have to find a different one or build your own.

Share this post


Link to post
Share on other sites

According to the manual using the hash in lieu of the query string is suppose to increase SEO.  How this could occur in an email, however, is beyond me.  The reason provided is as follows:  whereas web-crawlers count the same URL with different hashes separately, the same URL with different query strings is counted the same.

Do you agree?

Roddy

Share this post


Link to post
Share on other sites

It does not improve SEO, in fact it's detrimental. I don't know where you heard that. You actually have it backwards, all hashes belong to the same page, Google treats different query strings as different pages.

What does improve SEO is using a hash instead of nothing at all when using AJAX to change the page content. AJAX in itself is bad for SEO but some search engines offer the ability to use the hash to indicate that the page has changed, which reduces the harm of a Javascript-driven website. For Google, the hash must have a specific format, something similar to #/!/page-name, I'd have to look it up again to make sure I got that right.

In conclusion, don't use the hash to identify your pages.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×