Link to content on Github. How to remove %5c in filepath?

Hi! At the bottom of each page, I want to add that lastmod and the link to edit the file directly on github:

Like this:

 Last updated on {{ .Lastmod.Format "2006-01-02" }} - <a href="{{$.Site.Data.config.GitHubLink}}/{{.File.Path}}" rel="noopener">Edit Source</a>

When I click edit source, I get a 404 on github since the output is full of %5 to replace the / in the file path. How do I get the correct output to the github file using {{ .File.Path }}?

Use path function:

{{ $filePath := path.Join site.Data.config.GitHubLink (path.Clean .File.Path) }}
Last updated on {{ .Lastmod.Format "2006-01-02" }} - <a href="{{ $filePath }}" rel="noopener">Edit Source</a>
1 Like

Wow, that totally worked! I will look deeper into the docs next time.

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