Using relref with files


I am new to Hugo and I am having issues with I am trying to build a simple website (not a blog) for a hotel and creating my own theme along the way.

So far the themes/hotel/layouts folder contains:


and the contents folder contains:


At the end I want the HTML pages to be created to be:


In the theme’s menu.html template (included using partial in index.html and single.html), I am trying to add a link to all the pages of the website. This works:

<a href="{{ relref . “” }}">Contact
<a href="{{ relref . “rooms/” }}">Contact

but I don’t manage to get a link to the pages created from

<a href="{{ relref . “” }}">Homepage
<a href="{{ relref . “rooms/” }}">Our rooms

returns an error "error calling relref: No page found with path or logical name “”.

I read the doc and some of the posts here regarding “” but there is clearly something I don’t understand so I would be grateful if someone could shed some light on this for me.

Also if there is a particular section of the documentation or a particular theme that could be useful for the kind of website I am trying to build, please let me know.

Many thanks for developing Hugo!

I guess the cross references doc doesn’t explicitly say so, but it points to single content, not index pages.

Check out the section menu for lazy bloggers for an example of what you are trying to do. :slight_smile:

1 Like

Thanks Maiki!

I realised that the public/rooms/index.html was not even generated so I added a layouts/_default/list.html file.
I tried adding the code from section menu for lazy bloggers and it created one line:

<a href="/rooms/">Title of rooms' page</a>

so I guess I have a way out now but I still don’t know how it would work if I had more than one page (eg for /rooms/ and /restaurants/): instead of

range .Site.Menus.main

I guess it should be a test whether the menu corresponds to rooms/

As for the link to the homepage layouts/, should I just use:

<a href="/">Home</a>

Thank you for the help.

Ya know, slugs of pages may change if they are updated, and the ref shortcodes are there to accommodate those. But how often are you gonna change your sections? I feel it becomes an IA issue, before a link to the correct URI issue, ya know?

So I would link to the home and sections hard (or over a range if that works), rather than trying to get ref to work. :slight_smile:

1 Like

Thanks, that’s a fair advice. I will use hard coded links for the moment - I’m just trying to get my head around Hugo by using more and more of its features.
Just to be complete, I also found this about a similar issue.