Making other (non-blog) html pages available from my Hugo site?

My Hugo site is served from a VPS; I develop locally, and then rsync all the files to a directory on the VPS. This works fine.

However, I have another bunch of files - in this case presentations developed with reveal.js - which I’d also like to make available. The trouble is, I’m not sure where or how to serve them so that can be displayed with an appropriate url.

For example, I’ve added a directory “Talks” to my Hugo’s public directory. In that directory are the reveal.js files, the talk files, and various media and other files needed. I’ve set everything up to use relative addresses. Suppose the blog site is https://mysite.net. I’d hope that something like

https://mysite.net/Talks/about_nothing.html

would work, but of course it doesn’t - it just gives me a 404 error. Should I be adding the Talks directory to the static directory … or somewhere else?

What do I need to add - either in my configuration, or in theme files, or elsewhere, to allow me to access html pages in a non-blog directory? And where should those files sit?

[ I know that questions similar to this have been asked before, but I haven’t been able to work with any of the answers. ] Many thanks.

Short answer: Putting that in static should work.

TL;TR:

But if you

  • generate the site to /mysite/public
    • the links where you refer to have be correctly setup.
  • copy all talks to /mysite/public/Talks
  • rsync /mysite/public/** to /htdocs

any real webserver should be able to serve

  • your blog at: https://mysite.net/
  • your talk at: https://mysite.net/Talks/about_nothing.html

If that is not the case:

  • something seems to be wrong with your webserver setup
  • if you try to serve using hugo server → don’t do that, it’s a development dev server with limited options.

OFC with this setup hugo does not know anything about your Talks. But proper links should work

if you put all your talks in /mysite/static/Talks

  • hugo will do the copy from /mysite/static/Talks to /mysite/public/Talks for you
  • depending on your theme /templating code ease up link generation.

That said both things will work

  • keep the Talks out of hugo and just do two rsyncs
  • move them to static

depending on integration of Blog and Talks you might want to use a mixed approach, use assets… but that’s hard to tell

Thank you very much! My web server is Caddy, within a Docker container, and which acts as a reverse proxy, serving Lets Encrypt TLS certificates to all my various containerized apps. Caddy is designed to be very simple to deploy, with one directory designated as the root of the files to be served. Currently this simply points to where my Hugo files sit.

I’ll shift the directory Talks into static and see how I go!

My current theme is hugo-clarity, but I might switch to PaperMod which has some advantages, I think.

Again, many thanks.

Think that might be the main point.

Your common caddy root folder in my list above would be /htdocs which I assume is not part of the url.

So if

  • you place a file at /htdocs/Tasks/about_nothing.html on your caddy* the url https://domain/Tasks/about_nothing.html should not throw a 404.

And that’s what you wrote you did.

I would first check that this works. Nothing to do with hugo.

  • typing the url in a browser manually should work

Keep in mind that urls are and filesystem pathes might be case sensitive.

So just moving to static might not help

Worked it out! And I should have checked this first: I’d changed the Docker bind mount in my Caddy container for the directory to be served. However, I needed to stop the Caddy container, remove it, and restart a new container with the new parameters. And it now works fine. My apologies for wasting bandwidth and your time.

1 Like