HUGO

How to change a list items link?

I want a list of external links so in the screenshot below how can I change each items link to go to an external link that is specified the respective page. For example the first item “Audacity” would link to https://www.audacityteam.org/ rather than https://.../links/010/


I am currently using the PaperMod theme but as I understand it would be similar regardless of the theme. I did see the .Title variable used in /hugo/themes/PaperMod/layouts/list.html but no mention of the data or author so I think that is the wrong file

mkdir -p layouts/_default
cp themes/PaperMod/layouts/_default/list.html layouts/_default/

Then, in layouts/_default/list.html, replace:

<a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ .Permalink }}"></a>

With:

{{ $href := .Permalink }}
{{ with .Params.external_url }}
  {{ $href = . }}
{{ end }}
<a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ $href }}"></a>

Then add an external_url to the frontmatter as needed. For example:

---
title: "Audacity"
date: 2021-07-02T08:22:26-07:00
draft: false
external_url: https://www.audacityteam.org/
tags:
  - Media Production
---

That worked perfect, thank you very much

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.