# Help Anchor

**URL:** <https://discourse.gohugo.io/t/help-anchor/1257>\
**Category:** support\
**Created:** [June 1, 2015, 8:33am UTC](https://discourse.gohugo.io/t/help-anchor/1257 "2015-06-01T08:33:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tapelavoine](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tapelavoine/32/417_2.png) [@Tapelavoine](https://discourse.gohugo.io/u/Tapelavoine)\
**Post date:** [June 1, 2015, 8:33am UTC](https://discourse.gohugo.io/t/help-anchor/1257/1 "2015-06-01T08:33:44Z")

</div>

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 [http://gohugo.io/](http://gohugo.io/)).  
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” \>}})  
bla  
bla

## Foo

but where do I put that ?

Thanks for help!

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 1, 2015, 10:12am UTC](https://discourse.gohugo.io/t/help-anchor/1257/2 "2015-06-01T10:12:35Z")

</div>

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:

> **[Functions Quick Reference](http://gohugo.io/functions/)**
>
> Comprehensive list of Hugo templating functions, including basic and advanced usage examples.

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

---

<div class="post-metadata">

**Author:** ![Tapelavoine](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tapelavoine/32/417_2.png) [@Tapelavoine](https://discourse.gohugo.io/u/Tapelavoine)\
**Post date:** [June 1, 2015, 2:11pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/3 "2015-06-01T14:11:45Z")

</div>

Hi!  
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/post.md#who” \>}}{{\< relref “blog/post.md#who” \>}} in my post and an id in a node page ?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 1, 2015, 3:58pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/4 "2015-06-01T15:58:41Z")

</div>

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

So given [my-blog-post1.md](http://my-blog-post1.md):

```auto
# This is a title

And some text

```

And then [my-blog-post2.md](http://my-blog-post2.md):

```auto
# This is another title

And some text. And a link [back to post1]({{< relref "my-blog-post1.md#this-is-a-title" >}})

```

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:

```auto
<a href='{{ relref "my-blog-post1.md#this-is-a-title" }}' ...

```

---

<div class="post-metadata">

**Author:** ![Tapelavoine](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tapelavoine/32/417_2.png) [@Tapelavoine](https://discourse.gohugo.io/u/Tapelavoine)\
**Post date:** [June 3, 2015, 1:35pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/5 "2015-06-03T13:35:06Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 3, 2015, 1:57pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/6 "2015-06-03T13:57:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tapelavoine](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tapelavoine/32/417_2.png) [@Tapelavoine](https://discourse.gohugo.io/u/Tapelavoine)\
**Post date:** [June 4, 2015, 3:26pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/7 "2015-06-04T15:26:29Z")

</div>

This is a line from my menu:

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

```

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

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 4, 2015, 4:36pm UTC](https://discourse.gohugo.io/t/help-anchor/1257/8 "2015-06-04T16:36:54Z")

</div>

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