Using "url" to create site structure

Is using “url” to create site structure a good approach?

Use case:

Directory structure:

  1. example.com/content/tutorials/java/some_tutorial

  2. example.com/content/tutorials/java/another_tutorial

  3. example.com/content/tutorials/python/another_tutorial

  4. example.com/content/howto/java/some_howto

  5. example.com/content/howto/java/another_howto

  6. example.com/content/howto/python/some_howto

Desired URL structure:

  1. example.com/java/some_tutorial

  2. example.com/java/another_tutorial

  3. example.com/python/another_tutorial

  4. example.com/java/some_howto

  5. example.com/java/another_howto

  6. example.com/python/some_howto

Now to achieve this I’m using “url” in each post’s front matter. For example for some_tutorial I’m writing below:

url: /java/some_tutorial

It’s working fine. I just want to know whether this is a good approach or is there a better way?

Bonus question: I want a different sidebar for “tutorials” and “howto”. How can that be done?

I don’t know if it’s “good” or not, but if setting url in front matter works for you, then that’s good enough. You can also set permalinks in your site config. The permalinks documentation shows the available values.

I tried some of that early with my site. Eventually I gave up on permalink manipulation or manually produced urls and reorganized the content folder to match my site’s desired URLs.