Link to list.html from single.html for a section

I have several sections with multiple posts. In the list.html template I render all the posts for each section and in the single.html template I show each post.

How do I create a link in single.html that directs back to list.html for each section?

Example: I’m viewing post/firstpost.html and I want to click on a link that redirects to post.html. I’m viewing project/firstpost.html and I want to click on a link that redirects to project.html

Layout:

.
└── layouts
    ├── _default
    |    |── list.html 
    |    |── single.html 
    ├── section
         |── post.html 
         |── project.html 

Content:

.
└── content
    ├── post
    |   ├── firstpost.md  
    |   └── secondpost.md
    └── project
        ├── firstpost.md
        └── secondpost.md

Well, first post, but I hope I can help and give something back :wink:

Variables | Hugo gives a solution:

<a href="{{ .Params.Section | urlize }}">Back to Section</a>

This should do the job - not tested.

[edit] (found in another topic)

1 Like

Thanks. Just saw your edit now. I tried your previous suggestion earlier, but it didn’t work so I started playing around and just took a step back and realized how simple it actually was to solve. Thanks for helping out.

First one was some Kind of a guess - it worked this way for categories.

Just for learning and better understanding: Why is not possible to urlize .Section?

Does anybody found an official way to do that?

Anything better than this?

{{ (.Section | urlize) | absLangURL }}/