# Amp page linking to other amp pages

**URL:** <https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046>\
**Category:** support\
**Created:** [June 17, 2017, 12:28pm UTC](https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046 "2017-06-17T12:28:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuafinch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/joshuafinch/32/3364_2.png) [@joshuafinch](https://discourse.gohugo.io/u/joshuafinch)\
**Post date:** [June 17, 2017, 12:28pm UTC](https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046/1 "2017-06-17T12:28:04Z")

</div>

Hi there, recently started using Hugo and i’m enjoying it - having a little trouble with my template though.

I have an amp version of my home page - and all the links on my homepage to blog articles, are pointing at the html version instead of their respective amp versions.

Is there a way I can get the permalinks to point to the amp version if the current page is the amp output format?

The below code is what i’m using to generate the homepage’s posts, is there a nice way to get the `.RelPermalink` to point to the amp version, if the homepage is currently an amp version of the website?

```
{{- range $paginator.Pages }}

    <article>
      <header>
        <h1><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
      </header>
      {{- if .Summary }}
      <section>
        {{ .Summary }}
      </section>
      {{- end }}
      {{- if .Truncated }}
      <footer>
        <a href="{{ .RelPermalink }}">Read More…</a>
      </footer>
      {{- end }}
    </article>
{{- end }}

```

Thanks in advance,  
Joshua

---

<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 17, 2017, 1:05pm UTC](https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046/2 "2017-06-17T13:05:50Z")

</div>

`Permalink` and `.RelPermalink` will alsways point to the main output format (the first)

See

> **[Custom Output Formats](https://gohugo.io/templates/output-formats/)**
>
> Hugo can output content in multiple formats, including calendar events, e-book formats, Google AMP, and JSON search indexes, or any custom text format.

---

<div class="post-metadata">

**Author:** ![joshuafinch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/joshuafinch/32/3364_2.png) [@joshuafinch](https://discourse.gohugo.io/u/joshuafinch)\
**Post date:** [June 17, 2017, 1:47pm UTC](https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046/3 "2017-06-17T13:47:01Z")

</div>

Thanks for the response, so I guess I’ll have to in the amp version of the template use:

```
{{ with .OutputFormats.Get "amp" -}}
    <a href="{{ .Permalink }}"></a>
{{- end }}

```

Which is great for any of my main files, but as for my markdown content files - is there a way to get those to conditionally link to their respective amp versions?

Is there a variable that can give the current output format being used? Then i might be able to prefix the url’s in the markdown with `/amp/`

---

<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 17, 2017, 2:36pm UTC](https://discourse.gohugo.io/t/amp-page-linking-to-other-amp-pages/7046/4 "2017-06-17T14:36:41Z")

</div>

Re. content files:

- Either do `{{< relref "mypost.md" "amp" >}}`
- Create 1 shortcode per output format, i.e. `linker.html` and `linker.amp.html` or whatever.

Note that the `.Content` itself is currently fixed (one for all output types), but we do some special hackery with the shortcodes. This may be improved on in the future.

There is no exported value that tells you what is the “current output format”. I may expose that, but I suspect it will confuse more than it will help.
