HUGO

Content Organization

I’m starting up a new project and I’m thinking about the structure. I’ll have about 200 markdown posts.

This is the structure I’m thinking of doing:

content
  |--- _index.md
  |--- post1.md
  |--- post2.md
  |--- post3.md
    ....
  |--- post200.md

This way, all URLs will be example.com/post1 which is what I want… However, I would prefer having all posts in a folder for better organization, like so:

content
  |--- _index.md
  |--- myposts
          |--- index.md
          |--- post1.md
          |--- post1.md
          |--- post2.md
          |--- post3.md
               ....
          |--- post200.md

Is there a way to use the above structure and maintain the same URL structure as in the previous example? So example.com/post1 and not example.com/myposts/post1.

Check out the URL Management page of the documentation.

Thanks. I looked through the documentation prior to making my post as I wasn’t sure if this is possible.

After some thought, this is the structure and URLs I’d like to create:

content
  |-- _index.md
  |-- myposts
          |-- life
                |-- _index.md
                |-- post1.md
          |-- work
                |-- new-york
                      |-- _index.md
                      |-- post2.md

URLs:

myposts --> /
myposts/life/ --> /life/
myposts/life/post1/ --> /life/post1/
myposts/work/new-york/ --> /new-york/
myposts/work/new-york/post2 --> /new-york/post2/

Is this possible? If so, can you give some pointers on how to achieve this?

Find out more about the slug and url frontmatter.

You can structure your folders as sorted or chaotic as you want. Just add url with the resulting URL you want and “all is well”.

If you are less chaotic, try using slug and you can name the files the way you want while having a readable link structure.

Thanks. It seems I’ll need to reconsider my structure as providing a url for each post (thousands) doesn’t seem like a good long term situation The same with using slugs. Appreciate the reply.

I’m starting up a new project and I’m thinking about the structure.

If it’s a NEW project then add the parameters to your archetypes. If it’s not reused material, then using the hugo new command with an existing archetype structure will not end you up in “providing an URL for each post (thousands)”. Re-read your initial post. You talk about a NEW project with 200 markdown posts. Not thousands of already existing posts.

Appreciate the thought. But more appreciating exact problem descriptions.

Point taken. Thanks for the feedback.