[solved] Generating the canonical page reference for a section's list?

Imagine your homepage looks like this:

Welcome to the Hugo Cookbook!
-----------------------------

recipes       [see all]    authors [see all]
-----------------------    -----------------
1.) Hugo Chocolate Cake    1.) Julia Child
2.) Hugo Tiramisu          2.) Gordon Ramsay

The question at hand: Is there a way to generate the [see all] link targets, or do you just hardcode /<section-name>/index.html?

In other words, given only a string that you know that represents the name of a section ("recipes", "posts", "authors", etc.), how would you generate the URL that corresponds to that section’s list page?

I discovered .Site.GetPage and I’m using that now to get a page, which I then pull the permalink from. My use of it looks like this:

<a href="{{ (.Site.GetPage "section" .resourceType).Permalink }}">
  see all
</a>

where .resourceType is a string variable I control that contains the name of a section.

1 Like

Thanks for the tip! I was struggling with this last night.

https://discuss.gohugo.io/t/html-links-for-tags-and-categories/3567/3 refers.