Knowing previous page without cookies


I am trying to use Hugo (customising a theme) for sharing some knowledge. Considering all my content would likely be stored in pages, I might have to create different routes.
I can create two menus, route1 and route2. Each menu can have a list of possible pages, with an order.
However, when you press the first link in route1 and you load the corresponding page, I would need to keep displaying route1 menu.
This requires either the knowledge of previous page or the previous click, which it might be difficult to realise without creating cookies.
Which should be the easiest (and the most native way) to achieve this with Hugo?
I can obviously use something else rather menu, like categories. But if a page is in multiple category, I would need to compose the navigation menu on the side based on the category I was browsing with the previous page (which of course can be in multiple categories too).

Any idea is appreciated!

thanks in advance


I don’t see a way for you to do this that doesn’t envolve javascript, or duplicate content.

Duplicate content is a bad practice, because it’s harder to manage and reduces your SEO rankings.

Javascript can use cookies or the localStorage of the browser.

Not for content duplication too honestly. SEO isn’t a problem, I am working on something would be used on private environment.
I am actually exploring (and I might be totally wrong) page bundles for content organisation. They should probably do what I need/want.
I need to make some tests. I know what I want to do it’s not necessarily something considered in a blog engine and pertain more to CMS systems.


Two ways:

1.) history.back() in javascript leads the user back to the previous page. add a digit to the function and it goes x steps back.

2.) add a parameter that identifies each button, link or clickable element from the previous page and work with those on the current page.

@LunaticMuch I don’t have an answer or plan, but I’ve considered a similar scenario, something like an internal knowledge base with tutorial paths; on certain parts of a given path, it would be the same content as a different page in a different path, but I don’t really want folks choosing a fork in the road.

In theory I think something like transclusion would work, where the bulk of a step has text kept elsewhere, so it is updated for everywhere. In Hugo, we have a couple of apparent ways to accomplish this: shortcodes and front matter.

Using readFile in either case, to bring in the actual text from whichever file.

Okay, what’s the weakness here? I just can’t get over the fact that reusable content doesn’t make sense in different contexts, if it is written well. Because my goals are imparting knowledge, I think it is easier to craft individual nodes of information, and then creating a series or list from it, and letting viewers go through the pages at their discretion. It works better with the hyperlink format; I actually like folks using their own back and forth user agent motions.

I might have found something can work, perhaps much more simpler.
So, what I need is a menu different per section, not a template. Hugo easily allows multiple menu.
The point is how to call the right menu. I might use sections.
So, think we have a book. Chapters 1-10. I might give you two reading routes, the first includes all chapters, the other include only odd ones.
One section includes, etc…
The other section, can have just a hard link to chapters needed (ln -sf works)

Now, .GetPage “section” should be able to give me back the section name, and it can be used to call the menu with the same section name.

I am actually try to learn how to make Hugo printout the section name :smiley:

Maybe what you’re looking for

Yeah right. I am actually trying to make Hugo to print out all page variables. I’m following the manual at but I am doing something wrong.
The idea is:

hugo new section1/

to create a branch bundle. Section1 should be a section name now.

{{ printf "%#v" . }}

inside the single page should report section1, but it doens’t work. So I am misinterpreting something here.


{{ printf "%#v" .Section }}

Also, I recommend @kaushalmodi’s debug print component