Fetch parameter from another page

I have lots of internal links within my site. These are written in markdown [page-title](/page_url).

The pages being linked to have a Title within their front matter. Is there are a way to avoid repeatedly entering the [page-title].

I am thinking a shortcode like {{< link page_url >}} . But I don’t know how the shortcode could use page_url to fetch the Title from the target page.

Please can anyone help point me in the right direction?

In Hugo 0.22, being released on Monday, you can do:

{{ (.Site.GetPage "page" "blog" "mypost.md" ).Title }}

Etc.

In current Hugo version, GetPage is restricted to the “list pages” so you can do:

{{ (.Site.GetPage "home" ).Title }}
2 Likes

Sounds perfect. I will try that with 0.22 next week.
Thank you so much

And we will be able to do this with .Content? Pretty fantastic. Now I can remove the readfile hacks on the new docs. Thanks @bep!

1 Like