# Links to anchor in the same page

**URL:** <https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593>\
**Category:** support\
**Created:** [January 15, 2015, 10:15am UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593 "2015-01-15T10:15:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toorop](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@Toorop](https://discourse.gohugo.io/u/Toorop)\
**Post date:** [January 15, 2015, 10:15am UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/1 "2015-01-15T10:15:04Z")

</div>

Hi,

I do not find a way to add links to anchor on a page (other than writting raw html).

Something like :

```
[Jump to Foo](#Foo)

## Foo

```

Doesn’t works because of the unique identifier added to html tag :

```
<h2 id="Foo:4a1318da06786ac52626178ca960109e">Foo</h2>

```

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:** [January 15, 2015, 2:20pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/2 "2015-01-15T14:20:22Z")

</div>

Seeing that id I know you use the “latest and greatest” - there is shortcodes called ref and relref that fixes this. And there is an option to turn off that extra id, I think.

I suggest you look in the current /docs (start a hugo server in the docs folder) and read more abut it there ., somewhere.

---

<div class="post-metadata">

**Author:** ![Toorop](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@Toorop](https://discourse.gohugo.io/u/Toorop)\
**Post date:** [January 15, 2015, 4:00pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/3 "2015-01-15T16:00:56Z")

</div>

Thx @bjornerik thanks too your reply i’ve found the solution:

```
[Foo]({{<ref "#foo" >}}) 
bla
bla
## Foo
```

---

<div class="post-metadata">

**Author:** ![rjmaris](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@rjmaris](https://discourse.gohugo.io/u/rjmaris)\
**Post date:** [November 9, 2015, 2:22pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/4 "2015-11-09T14:22:41Z")

</div>

My problem is: I want to supply a URL including anchor in an email. But the identifier is undesired. Why? People may be hesitant to click a link that contains a sort of hash code, because hashes and other code stuff in emails is very often used to identify WHO clicked the link in an email.

---

<div class="post-metadata">

**Author:** ![carlcaulkett](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/carlcaulkett/32/19389_2.png) [@carlcaulkett](https://discourse.gohugo.io/u/carlcaulkett)\
**Post date:** [December 9, 2017, 3:30pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/5 "2017-12-09T15:30:53Z")

</div>

Hello @bep. I’m trying to find out about links to anchors on a page. However, I don’t appear to have a/docs folder in my Hugo installation. Where else can I find the required info?

---

<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:** [December 9, 2017, 3:46pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/6 "2017-12-09T15:46:02Z")

</div>

@arlcaulkett please don’t address me by name for general Hugo questions that everone can answer.

---

<div class="post-metadata">

**Author:** ![carlcaulkett](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/carlcaulkett/32/19389_2.png) [@carlcaulkett](https://discourse.gohugo.io/u/carlcaulkett)\
**Post date:** [December 9, 2017, 3:59pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/7 "2017-12-09T15:59:44Z")

</div>

> [@bep](#):
>
> I suggest you look in the current /docs (start a hugo server in the docs folder) and read more abut it there ., somewhere.

My question was in response to a specific message that _you_ posted where you mention a folder that doesn’t exist on my Hugo installation. If you feel that I was being unreasonable in addressing the question about _your_ post to you, then that’s your prerogative, of course.

I realise that our internet relationship has not got off to a great start. In my defence my previous mentions of you by name were in response to automated anti-spam messages, but which appeared to be directly attributable to you. My mistake, and, for that, I apologise. I do not apologise, however, to being royally pissed off with being presented with a message telling me that I was prevented from posting for a 240 hour period.

I refer you to this tweet: [https://twitter.com/carlcaulkett/status/937846351852740608](https://twitter.com/carlcaulkett/status/937846351852740608)

---

<div class="post-metadata">

**Author:** ![carlcaulkett](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/carlcaulkett/32/19389_2.png) [@carlcaulkett](https://discourse.gohugo.io/u/carlcaulkett)\
**Post date:** [December 9, 2017, 4:24pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/8 "2017-12-09T16:24:43Z")

</div>

That having been said. I really like Hugo as a piece of software, and I would like to be on friendly terms with all of the people involved with it. Whaddya say?

---

<div class="post-metadata">

**Author:** ![bickhaus](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bickhaus](https://discourse.gohugo.io/u/bickhaus)\
**Post date:** [March 5, 2018, 3:31am UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/9 "2018-03-05T03:31:18Z")

</div>

I am also having a problem getting links to other parts of the same page to work. I tried using the `ref` and `relref` shortcodes to no avail. These are the methods I have tried:

```auto
## Foo

[Foo](#foo)
[Foo]({{<ref "#foo" >}})
[Foo]({{<relref "#foo" >}})
<a href="#foo">Foo</a>

```

In each case, the link that gets created ends up being `baseURL/#foo` which redirects to the homepage when clicked. I am using the Hugo Dusk theme and initially, canonifyURLs was set to true. I thought that may have been the problem, but setting it to false did not help. Currently, I am getting the desired effect by typing out the name of the page in the link:

```auto
[Foo](/name-of-page/#foo)

```

Does anyone have an idea what setting I may need to change to get the ref shortcode working properly?

---

<div class="post-metadata">

**Author:** ![theodore-q](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/theodore-q/32/7078_2.png) [@theodore-q](https://discourse.gohugo.io/u/theodore-q)\
**Post date:** [October 3, 2018, 8:58am UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/10 "2018-10-03T08:58:27Z")

</div>

I figured out a solution so I thought I’d leave it here for anybody else looking:

```
<a href="{{.URL}}#foo">Foo</a>
```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 15, 2023, 12:52pm UTC](https://discourse.gohugo.io/t/links-to-anchor-in-the-same-page/593/13 "2023-06-15T12:52:57Z")

</div>


