Hugo Theme - Changing rendered pages/routes based upon site config

Hi All,

I’m working on a Hugo Theme for community groups, focused around events, speakers and community content. There are a few different use-cases where I think this theme would be valuable for an end-user -

  1. A single group, e.g. a meetup group for a given topic in an area
  2. A platform for groups, e.g. a directory of groups, speakers, events, etc. SImilar to the demo site that is shown here.
  3. A conference scenario.
    • Option A: For a brand that has many “events” throughout the year, and wants to show those different events on their page. They may also smaller groups within their larger community base. Think of something like Kubecon/Cloud Native Foundation, where they have focused/targeted groups, and many events that run throughout a year.
    • Option B: For a “Single Conference”, i.e. there is just 1 event (with many activities), and 1 group. When they have their next conference, they may deploy an entirely new instance of the site/theme.

Now with that context out of the way, this is the first theme that I’m building for hugo, and I feel it’s coming along well so far. However, I’m looking to get some perspectives from others in the community, as I’m a little unsure on the best way to make sure the theme is flexible for the above scenarios.

Current thoughts/questions -

  • I have a directory based archetype for “Groups”, which contains a folder for sponsors and organizers. In the main directory, they can host their own pages, i.e. About Us, Code of Conduct, etc. (Example content)(Example Page).

    • I have a parameter value in the Site.Config for the user to determine if the site is in a “Single Group” or “Multi Group” mode (i.e. scenario 1 or 2 from above). If the site is in a single mode, then it shows a slightly different navigation bar, to reflect that it’s a single group.
    • The question: Let’s assume they have created just one group, azure-thames-valley as above, and no other groups. Is there a way that I can make /group map to groups/azure-thames-valley, groups/about map to groups/azure-thames-valley/about, etc? I’m currently using aliases which “work”, but redirect to the new link. I was thinking of an option to almost conditionally alter the hierarchy of the rendered pages, based upon that Site Config
    • My Thought: Given that I want to have a slightly different UI for the Individual Groups, I’ve considered having an archetype for “Single Group” vs an archetype for “Multi Group”, and then let the user generate what they need. Then, the site config option just changes which style of navigation would be available.
  • I also have a directory based archetype for “Events”, which contains a folder for activties (think talks, breakout sessions, etc.) and organizers.

    • Similar to the above question, what options would there be for me to set a “single event mode” for the theme, so that if a user navigates to /event, then they are routed to the content in event/myevent? I’ve again considered a “Single Event” vs “Multi event” archetype. I wondered if this type of scenario is typically handled using archetypes, or through some kind of logic/configuration in the theme?

If i’m going in a completely strange direction, or you have other ideas/suggestions, I’d love to hear them :slight_smile: This is equally a learning experience for me in hugo themes/templating, and feel like i’ve picked up a lot along the way thanks to this community (So a big thank you already for the docs and discussions!)

Either add a permalink structure for your sections or add a “slug” or “url” frontmatter parameter for each group, groups/about etc.

Aha, thank you - I hadn’t thought about slugs/the permalink structure as an option here! So if I’m interpreting those docs correctly, then the “Hugo Way” to do this would be to have a different URL path based upon which “configuration” of the site you want to deploy.

I think that would then eliminate the need for the Single Group/Multi Group Site Config parameter that I mentioned, and the user could then control it through the permalink structure and navigation information directly.

This is very helpful, thank you!