Dear all,
I have added a widget to a sidebar. I try to figure out how to add a hyperlink in this widget to a file related to the current displayed post. The file in question stands in the directory of the post, i.e.
./content/posts/my-post/my-file.pdf
The code of the widget I created is:
What is displayed is a link to the current page, but not to the file.pdf
I may change {{- .Title -}} but I don’t know what syntax I should use instead.
Thank you for your help.
Thank you very much for your swift reply. I was just logging in to reply to myself as I found a solution which may not be as elegant as yours. I do not wish to hard-code the name of the file in the widgets file. So I wrote this code which makes it:
{{ with .File }}
<a class="widget-download__link widget__link transition" href="../{{ .TranslationBaseName }}.pdf" target="_blank">
{{- .File -}}
</a>
{{ end }}
Unless there is a way to avoid hard-coding the name of the file as this name changes for every post.