Site name: https://hopeful-ritchie-43cd68.netlify.app/
I am trying to follow this support guide in order to add a blog to my website: [Support Guide] Can I deploy multiple repositories in a single site?
It requires that instead of serving the blog at https://hopeful-ritchie-43cd68.netlify.app/ (bare url), it should be served at https://hopeful-ritchie-43cd68.netlify.app/blog.
Here is an example of a successful build Netlify App but it is hosting on the bare url despite me setting the baseurl to /blog
in the build command and /blog
in hugo’s config.toml. So it seems like the baseurl I’m setting is being ignored?
Any help is appreciated and I’m happy to answer any questions
Hi @Ethicli,
Hugo’s baseURL
config is irrelevant in this context and you should change it. Hugo uses base URL to determine the value used in Permalinks and Sitemaps. It should always be your website’s home page’s URL with a /
at the end.
Coming back to your question, to make that happen, you’d have to configure Hugo to export the blog’s pages at public/blog
. However, Netlify will always need an index.html
at the root of the website and in its absence, you’d be shown a 404 page as the home page.
You could also achieve this with redirects, but I don’t think redirecting the home page is a good idea.
BUT, if your question is that, you already have a website working and you wish to publish your Hugo website inside that already working website, then it might be a problem. There would be 2 ways to handle this. You’d have to configure our current build command to build your main website, then build the Hugo website and copy its built files into the main website’s publish folder. This might be tricky to do.
Instead, you could publish your Hugo website as a separate website and use rewrites in the main website like:
/blog/* https://hugo-website.netlify.app/:splat 200!
Hi there. Previously I was trying to do what you said here,
BUT, if your question is that, you already have a website working and you wish to publish your Hugo website inside that already working website, then it might be a problem. There would be 2 ways to handle this. You’d have to configure our current build command to build your main website, then build the Hugo website and copy its built files into the main website’s publish folder. This might be tricky to do.
but I realized it was unnecessarily complicated. So I am now trying to use the redirect method.
I’ve tried setting hugo’s destination to /blog/dist
instead of the default /dist
but you just helped me realize that it should be /dist/blog
instead! Thank you. I will go try that out now
update:
It now shows the homepage at /blog like I wanted
https://60f32adfa4990400087c9795--hopeful-ritchie-43cd68.netlify.app/blog/
But linking to css and other things isn’t working properly.
I think it will just be best for me to use a subdomain instead of a subdirectory