I just started playing around with Hugo and so far it seems pretty awesome
I would like my blog to be separate from the rest of the site. So the idea is that the blog would be accessible via
/blog, which I have managed to do by renaming the
post directory to
However, I can not seem to figure out how to make taxonomies (I’m interested in categories and tags at the moment) to appear under
/blog as opposed to under
/. So, I would like Hugo to place categories under
/blog/categories (instead of
/categories) and tags under
/blog/tags (instead of
I have found an issue filed in GitHub (https://github.com/spf13/hugo/issues/1208) which seems to describe this issue, but it does not seems to have gone cold
Is this at all possible in Hugo (or perhaps, is it planned)?
Any help and insight would be appreciated.
You could make your blog a “language”. Which is kind of hackish, but will give you what you want.
Thank you for your answer!
Setting blog as a language does sound hackish indeed. I’m guessing it would cause issues if I wanted to actually use languages later down the line.
I can probably have a URL rewrite for this on the server-side, but that partially defeats the purpose of a static blog, not to mention that things would break on
Aside from the linked GitHub issue there any other place I could suggest an implementation of this feature? I’m sure something like this would be useful to folks looking to move non-blog sites from CMSs like WordPress and Jekyll.
Well in the Github issue you referenced there is this comment that offers a workaround without hacks.
The limitation is that you will only have tags & categories under /blog/ not site-wide (but then that’s what you’re asking for).
I forgot to mention that I tried that suggestion… I got the following error when I tried that suggestion –
ERROR 2017/04/05 22:14:46 0 : template: theme/_default/summary.html:6: bad character U+002F '/'.
My Hugo version is as follows –
Hugo Static Site Generator v0.19 darwin/amd64 BuildDate: 2017-02-27T11:21:29+01:00
Actually… I managed to get this to work (still new to the templates syntax!).
I understand this is somewhat of a hack, but for lack of a better solution, as a new user, it would have been useful for this to be documented in the main Hugo docs.
It seems like there is a new documentation effort by @rdwatters underway (great work btw!) – Perhaps this trick could be mentioned somewhere to give new users looking for something like this a head start?
Thank you for the help!
Out of curiosity. Did you manage to get the solution from the Github comment to work or did you modify it?
IMO it’s not really a hack. Just a different way of doing things in Hugo than the default way.
On a final note we all had a bit of a rough start with Hugo. This forum is a great resource to find solutions.
And once you get familiar with Hugo, you’ll see that you can do lots of cool things with front matter, parameters, functions, partials & shortcodes.
Things that in other platforms you would need some really nasty CSS/JS hacks to achieve (believe me I know since I come from Blogger and Tumblr).
No, I didn’t need to change anything, I just had a silly syntax error!
FWIW, just in case it’s of use to anyone, to make this less ‘ugly’, you can use YAML in your frontmatter instead of TOML to avoid the weird quotes around
blog/tags in frontmatter (it’s awesome that Hugo is so flexible in this regard).
Therefore, the following block of TOML:
"blog/categories" = ["One cat", "another cat"]
"blog/tags" = ["One tag", "Another tag"]
- "One cat"
- "another cat"
- One tag"
- "Another tag"
You can make it simple, I did it this way.
In my front matter.
And in my
category = "category"
tag = "tag"
author = "author"
author = "/blog/author/:slug/"
category = "/blog/category/:slug/"
tag = "/blog/tag/:slug/"