Symlinks and duplicate content w/ different paths

We have versioned documentation and we’re trying to alias content via symlinks–which we have “working,” but not without errors when running hugo, e.g.:

ERROR 2018/02/26 16:34:07 Two or more menu items have the same name/identifier in Menu "sensu-core-1.2": "CHANGELOG".
Rename or set an unique identifier.

The URLs behave appropriately (/2.8 and /latest both work and point to the same content), but these errors cause hugo to exit non-zero–appropriately, I suppose.

So I have a couple of questions:

Is it intended for this to work? (I think the answer is no, and that it just happens to work.)
Are we doing it wrong?

I know we can do this with aliases, but then we have to maintain frontmatter for every page that should be “latest.” Or am I missing some other mechanism for aliasing.

Any suggestions would be super helpful.

How are you doing this in the frontmatter? Seems to be you could get this behaviour using something like this:

aliases: ["/latest","/2.8"]

We aren’t doing anything in frontmatter right now. We’re actually trying to figure out how to avoid that. If we do this in frontmatter, we’d have to automate the process, because otherwise we’d have quite a few files’ frontmatter to edit when we release a new version of the documentation.

Also, to clarify, what we’re currently doing is literally symlinking the latest -> 2.8

The problem is that the two versions of the same page will be assigned the same ID in the defined menu. Removing the ERROR message will not fix the problem with the menu. The menu logic needs to be adjusted for this case. The menu code is not mine, but you need to create a GH issue to track this.

@grepory Wouldn’t simply setting redirects work?

Redirect all /latest/* pages to /2.8/*… Then you need to update just that one redirect file on each version update. You don’t even need symlinks.

Is there a concept of redirects in hugo?

No, it depends on where you deploy your site.

Here’s an example Netlify redirect file; it redirects http://ox-hugo.scripter.co/test/ to https://ox-hugo-tests.netlify.com/ while retaining the URL prefix (So while the URL shows https://ox-hugo.scripter.co/test/posts/no-toc-in-summary--without-more/, it’s actually loading https://ox-hugo-tests.netlify.com/posts/no-toc-in-summary--without-more/).

I mention this example because it might apply to your use case too (show URL with /latest/ in path, but actually load pages from /2.8/?).

I am not a web developer, so forgive me if I am stating the obvious.

If you are using Netlify, its Redirect & Rewrite rules article would help.


Update: Add info about empty _index.md file.

I also need an empty _index.md for the test/ section so that Hugo generates a valid page for that.

content/test/_index.md

+++
title = "Test Site"
+++
1 Like

Ahhhhh okay, right. Yeah, my suspicion was that we were going to have to do URL rewriting/redirects somehow, but Heroku doesn’t support it. I had forgotten about netlify, though. Will ponder how we might be able to do this. Thanks.

Also, it appears that if we just use the static buildpack in heroku, then we can do this there as well: