Tags generated link to root instead of baseURL

I’ve been using Hugo for a while and it’s great, but I’ve noticed that when my HTML pages are generated, it seems like the tags at the bottom of the page are going to example.com instead of example.com/path (to use an example domain), which is what my baseURL is configured with.

Here’s some background, my configuration looks like:

baseURL = "https://writequit.org/book/"
...
# Enable tags.
[taxonomies]
tag = "tags"

I can go to https://writequit.org/book/tags and see the tags no problem. However, on any particular tag at the bottom of a post (let’s use architecture as an example), clicking on the tag links to https://writequit.org/tags/architecture instead of https://writequit.org/book/tags/architecture, so the link goes to a 404.

I’ve tried searching but I’m not sure how to get the tag links to use the baseURL instead of just the domain name.

Here’s my full config.toml, in case it’s helpful:

baseURL = "https://writequit.org/book/"
languageCode = "en-us"
title = "Commonplace Book"
theme = "ananke"

[params]
# Blog subtitle which appears below blog title. Supports markdown.
# subtitle = "[ezhil](https://github.com/vividvilla/ezhil) theme"
# Number of posts to show in recent posts list (Optional). Defaults to 10.
recentPostsCount = 10
# Content types which are excluded from recent posts and archive page (Optional). Defaults to ["page"]
excludedTypes = ["page"]
# Content types which are excludes Disqus comments (Optional). Defaults to ["page"]
disableDisqusTypes = ["posts"]
# If social media links are enabled then enable this to fetch icons from CDN instead of hosted on your site.
featherIconsCDN = false

# Main menu which appears below site header.
[[menu.main]]
name = "Home"
url = "/posts"
weight = 1

[[menu.main]]
name = "All posts"
url = "/posts"
weight = 2

[[menu.main]]
name = "About"
url = "/about"
weight = 3

[[menu.main]]
name = "Tags"
url = "/tags"
weight = 4

# Social media links which shows up on site header.
# Uses feather icons for icons. You can [search icon names from here](https://feathericons.com/).
[[params.social]]
name = "Github"
icon = "github"
url = "https://github.com/dakrone"

[[params.social]]
name = "Twitter"
icon = "twitter"
url = "https://twitter.com/thnetos"

[[params.social]]
name = "RSS"
icon = "rss"
url = "https://writequit.org/book/index.xml"

# Enable tags.
[taxonomies]
tag = "tags"

In your menu configuration use pageRef instead of url.

Do you mean like this?

[[menu.main]]
name = "Tags"
pageRef = "/tags"
weight = 4

I tried that, however, the links at the bottom of the post still go to https://writequit.org/tags/<thing> instead of the path with /book in it. I also tried changing it to pageRef = "/book/tags", however, that only affected the “Tags” link at the top of the page, rather than the links in the tags themselves.

I am unable to reproduce the problem as described, starting with a fresh site using the Ananke theme, served from https://writequit.org/book/.

Please post a link to the public repository for your project.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

I’ve opened the repository with the code in question: GitHub - dakrone/commonplace-book: My blog

$ git clone --recurse-submodules https://github.com/dakrone/commonplace-book

Submodule path 'themes/ananke': checked out '056246eb62b96c66d9ea55d9485053ae2c29bfd5'

That commit (056246eb) is dated Oct 28, 2020.

$ git submodule update --remote

Submodule path 'themes/ananke': checked out 'a1a99cf12681ad95b006e648a28139e6b9b75f09'

That commit (a1a99cf1) is the latest.

$ hugo server

Example path:
http://localhost:1313/book/tags/architecture/

Thanks, I hadn’t realized that a problem like that would be caused by a theme. I was wary of updating since that has broken other things in the past. Now that I’ve updated the tags issue has been fixed.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.