Fragment routing

Hello there,

On a few previous projects I worked on, using URL hash/fragment for routing seemed to be a common practice.

But I’m a bit confused looking at the Parser (fragment -> a) a return type of the Url.Parser.fragment function: is it supposed to be also used to parse slash-separated fragments (e.g. /#/foo/bar) the same way paths can be parsed, and how? If not, is there any plan to support it at some point? Or is the feature not really wanted in this module, maybe because it’s not considered such a good practice or because it should be easy to support it in a separate module?

Thanks! :slight_smile:

2 Likes

Yes is very unclear how to do this, seems that is not supported at all.

Here is a hacky way to do it by using the hash as the path:

https://ellie-app.com/3bTbc38PH8ma1

I will like to know if there is a better way I’m not seeing.

4 Likes

using the hash as the path

I was thinking about the exact same hacky way :smile:
But I wanted to know if I missed something.
Thanks for the working example anyway!

Two curious questions :slight_smile:

  1. Why do you consider the solution hacky? It’s a two-step process: First extract the hash, then treat it as a URL path and parse it.
  2. Why do you use fragment routing? I thought it was bad for SEO and stuff.

Why do you consider the solution hacky? It’s a two-step process: First extract the hash, then treat it as a URL path and parse it.

Building a fake URL that doesn’t represent any actual ressource feels a bit hacky to me.

Why do you use fragment routing? I thought it was bad for SEO and stuff.

The app won’t be exposed to search engines and the server may not be under my control anyway.

Hope this helps clarifying my post :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.