discordjs / website

The discord.js site what else
Other
183 stars 114 forks source link

feat(Router): use HTML5 history mode instead of hash mode #113

Closed megatank58 closed 2 years ago

megatank58 commented 3 years ago

This PR makes the router use history mode which changes all URLs from /#/ to /, by adding a 404.html which is a copy of index.html which serves the site as it normally would so refreshing the browser does not gives the github 404 page but instead shows the site

There is a caveat though, the responses will have 404 status code which might not be ideal for SEO, another option is to use the 404.html to redirect to index.html which will return the 200 code and behave the same way

A preview can be seen at the preview

Gawdl3y commented 2 years ago

There is a caveat though, the responses will have 404 status code which might not be ideal for SEO, another option is to use the 404.html to redirect to index.html which will return the 200 code and behave the same way

This is why we haven't done this. Returning a 404 status code on every page is definitely not desirable - and redirecting it to the anchored version doesn't really solve anything, as at that point you're just relying on the anchored version anyways. There is no functional difference between the two in the first place - having a single hash in the URL is not a big deal, and not worth hacky workarounds like this to avoid, IMO.

megatank58 commented 2 years ago

That makes sense, I'll close the PR then