Link Href to the correct pdf file

Viewed 183

I am working on a Hugo site and i need some help.

i have files that i have generated using pandoc/latex. The pdf files version of the website is located in a folder that says PDFs.

i want the html href to populate itself with the matching pdf file when "click to view pdf" is linked.

how would i do this in Javascript?

url: manual/company/culture/? file name/url when pdf is loaded :manual/company/culture/privacy-policy-index.md.tex.pdf

The pdfs are in the content folder

1 Answers

You can use a page bundle/page resources for this (https://gohugo.io/content-management/page-resources/). From the '.Page.Resources' variable you can get the URL of the first PDF in that specific folder and put it in the href. You do not need (or can do this with) javascript.

It looks like this:

<a href="{{ (.Page.Resources.GetMatch "**.pdf").RelPermalink }}">click to view pdf</a>
Related