One folder structure for two baseURL?

Hey there!
I have a question I don’t know to ask to Google or search here because I don’t know if this has a name or not.
I have a folder structure like this one.

- Content
+--- Folder1
    +--- index.md
    +--- pictures
        +--- Sub1
            +--- Picture1.png
        +--- Sub2
            +--- Picture1.png
+--- Folder2
    +--- index.md
    +--- pictures
        +--- Sub1
            +--- Picture1.png
        +--- Sub2
            +--- Picture1.png

In the .md file, I have a shortcode that can take the name of one of the subfolders to display the pictures it contains. At the moment, I’m displaying the content of each subfolder from the same index.md file if I go to http://example.com/Folder1 .
Now, I would like to do something different. While keeping the same folder structure, I’d like to have the following behavior instead:

  • If I go to http://example.com/Folder1 , the content of Folder1/Sub1 should be displayed
  • If I go to http://example.com/Sub2/Folder1 , the content of Folder1/Sub2 should be displayed
  • If I go to http://example.com/Folder2 , the content of Folder2/Sub1 should be displayed
  • If I go to http://example.com/Sub2/Folder2 , the content of Folder2/Sub2 should be displayed

Is this something possible with Hugo? Said a bit differently, I would like that http://example.com/ and http://example.com/Sub2/ kinda act as two different BaseURL showing two different set of pictures when I navigate. And when I’m on http://example.com/Sub2/, clicking a link to Folder2 should bring me to http://example.com/Sub2/Folder2

I think you should simplify your design; what you describe is… unusual.

If there’s something better to do with that design, I’m open to suggestion. :slight_smile:

To create a reachable URL it must be:

  • Backed by a file in the content directory, OR
  • A top level section, taxonomy, or term page, OR
  • An alias to another page

What you describe involves URLs that are not backed by a file, and where using an alias is nonsensical.

Start by creating a content structure that matches your desired URL structure, then figure out where to place the shared assets. It might be better to place them in the branch bundle instead of in the leaf bundle, or use global resources.

But if you were my client, I would forcefully push back against whatever requirement is leading you in this direction.

Hello,

Sorry for the (really) late answer. Thanks for your recommendation. I will consider this a solution even though I went a totally different way. I cheated the multilingual system provided by Hugo to keep the same folder structure and have different content accessible from different URL.

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