This is fundamentally the wrong way to do it, for a number or reasons:
- The URL can can be affected by configuration (
permalinks
) and front matter (slug
,url
), but you’ve hardcoded the result. - By the same token, there is not an efficient way to perform a reverse lookup from URL to
.File.Path
, which is what you need in order to.GetPage
Instead…
---
title: Post 1
date: 2022-02-04T18:58:11.000Z
draft: false
related:
- /post/post-2
- /post/post-3
---
Then:
{{ with .Params.related }}
{{ range . }}
{{ with site.GetPage . }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
{{ end }}
{{ end }}