Referencing a pdf works, but there is a warning on startup

I’m referring to a pdf using in a markdown file using [foo](/images/smile.pdf),
and it works fine, the pdf is displayed when the user clicks. But on startup
I see: WARN Page '/images/smile.pdf' not found in '_index'. I tried moving
the pdf file to /static/doc, but this doesn’t fix the issue.

What am I doing wrong? Thanks!

See this: Serving pdf files Hugo creates folders with "index.pdf"

1 Like

What theme are you using? This seems to be a warning from a link render hook.

1 Like

I’m using hugo-book theme.

The error is from the render-link hook in the theme:

1 Like

looks like there is a param, to disable that
{{- if .Page.Site.Params.BookPortableLinks -}}

  • maybe set that to false and see if your other markdown links are still working

  • if that does not work, you might consider to try hugos embedded link render hook by copying the content to _default/_markup/render-link.html (render-hook docs)

    your pdf file then has to be moved to the page bundle or the assets folder


without any link render hook and bare markdown.
if your file is in /static/doc/smile.pdf without any render hook it can be referenced as [smile](/doc/smile.pdf) in markdown (if your site is in a subfolder as [smile](/subfolder/doc/smile.pdf)

1 Like

Thanks, I’ll have to read more about render hooks.

Just noting that you’re not doing something wrong and you can safely ignore the warning since everything works as expected. The theme’s author could arguably check if the files / resources exist with a better method.

1 Like