Hi, I am new to hugo so forgive me if this turns out to be trivial, but I cannot find any satisfactory answers. Below you will find a link to a completely stripped down hugo file structure to explicitly demonstrate the problem I am happening. Actually, the readme file I have included probably explains the problem more clearly.
To summarise, I have a hugo site which runs perfectly when the baseurl is example.com.
However, I would like to deploy it in a subdirectory, say example.com/subdir.
What is the current best practice for doing this?
I have tried setting the baseurl to be example.com/subdir/ and played around wiith setting relativeURLs and canonifyURLs to true, but this doesn’t help. Some of the links then work, but others do not. But the problem is that some hyperlinks in the html and css start with a slash: /images/… (either accessing the assets or static folder). And hugo does not seem to know that I want these to refer to example.com/subdir as a base.
then the thumbnail appears with the correct image (located at example.com/subdir/images/image1_thumbnail.jpg), but its hyperlink refers to example.com/images/image1.jpg (which does not exist) rather than example.com/subdir/images/image1.jpg (which does).
Note that the hyperlink to “page 2” does work. On the other hand, if I do things like including relativeURL and canonifyURL to true, then the image links work perfectly, but the hyperlink to page 2 does not work anymore.
Well yes I tried putting a slash at the end, with no improvement. Saying “your theme is to blame” is precisely the question in some sense. I have made my own very basic theme following standard practices.
Hi - I have made a completely stripped down project structure (without any themes) to demonstrate the issue I am having. Please see the edited question.
Hi that’s very good. There are two follow ups however (but this should finalise it):
One of my links in a markdown file is to a pdf in a folder in static. I can’t seem to make the relref work here.
There is one other place where they occur - I have an element in the css file with background-image: url(“/image1.jpg”). Again, I don’t think hugo allows a shortcode in these files, does it?
Perhaps you suggest just hard coding it in? But the problem is that I haven’t finalised the name of the subdir folder! So it is possible it may change! So it would be useful for hugo to know about this somehow.
[Edit: perhaps useful for other newcomers : in reality, my<a href=...>s occur in a layout (html) file (specifically in a nav partial in my theme). The baseurl can be fixed by writing eg <a href="{{.Site.BaseURL}}about">about</a> to link to the subdir/about page.]