Help Anchor

Hi guys!
I’m trying to do a simple website with hugo, i used the hugo-base-theme as a start and I want that was my four links in my menu to have a anchor that link to the content in the page (like here
For now I just have one button who work with that line of code:
{{ if modBool $index 2 }}

{{ else }}
{{ end}}

but i don’t know why…
I find this code in an other topic:
[Foo]({{<ref “#foo” >}})


but where do I put that ?

Thanks for help!

The Foo thing you list there is creating a link from a content (markdown) page.

Have a look at the ref and relref template funcs:

One of these funcs are used to create the magic link above, with anchor and all.

Thanks for the answer!
I’m a big noob in dev so I don’t quite understand the use of relref
I have to put a line like this {{< relref “blog/” >}}{{< relref “blog/” >}} in my post and an id in a node page ?

It’s easier to understand this by just testing it.

So given

# This is a title

And some text

And then

# This is another title

And some text. And a link [back to post1]({{< relref "" >}})

I dont’t think you need the path (/blog), but test it.

In templates, i. e. not in content/markdown files, you will have to use the relref/ref funcs directly:

<a href='{{ relref "" }}' ...

aaah ok I’m getting it, I thought that the variable was sort of id… I put the relref function in my html and now when I click on the link it send to the adequate content but it only display the post without css or the rest of the site. The value that it send is /post/my_post/ am I missing something ?

Well, this is kind of hard to debug without seeing the complete project, but I have a problem seeing how the link should have anything to how the target looks. That sounds like a different problem.

This is a line from my menu:

<a href='{{ relref . "" }}' class="btn btn-success btn-lg" >Location</a>

The value that it return to me is /post/location/, I dont see what’s wrong…

/post/location sounds reasonable – but as I said, impossible to say without seeing the complete project.