[newbie] Page with PDF and raw HTML subpages/"attachments"

On my blog, I want to add a post like this:

+++
title = "Sample post"
+++

Here is some pdf: [demo.pdf](demo.pdf)

Here is some HTML example: [demo.html](demo.html)

where the generated URLs would look like this:

  • MYSITE.com/sample-post — this should be the “Sample post” rendered as HTML
  • MYSITE.com/sample-post/demo.pdf
  • MYSITE.com/sample-post/demo.html — I should be able to open this normally in a browser and view the demo

(How) can I do this in Hugo?

1 Like

Yes to at least the first two. Look into “page bundles”. There’s plenty of info on it in this forum or in the docs.

I’ve got /content/page/outsourcing/index.en.md to get:

 https://esolia.com/outsourcing/

I have an image in the bundle under the same outsourcing folder and I can access it like:

 https://esolia.com/outsourcing/eSolia-Post-Our-Solutions-Your-Challenges-2.png

You should try making demo.md to generate that html or literally putting demo.html in there to see if that works too.

First step is to learn about page bundles.

Thanks! The first two indeed worked by just putting the .md file as post/sample-post/index.md, and the .pdf as post/sample-post/demo.pdf.

Unfortunately, the demo.html doesn’t work with this method. What can I do to have it working too?

Hm, ok, for better or worse, it seems I can make the html work by putting it in:

  • static/post/sample-post/demo.html

and also adding the following line to my config.toml:

staticDir = ["static"]

Yes, Hugo just copies what is in static to the root of the published site.

So isn’t it possible to have an .html file in a page bundle ?

No way to add something in the frontmatter or else ? Putting a lot of html files in /static will be a complete mess after quite some time.

edit : actually i just realized i can just remove “.html” from the name of the file and it works and still got interpreted by the browser.

1 Like