Aliases not doing anything at all?

Hey everyone. I have a need to use the Alias feature, but I’m not sure if I’m doing it right.

I have 2 pages that I want to redirect to my more recent page. So in my more recent page (content/products/itmvc/) I made the front matter look like this:

+++
...
aliases = ["/pages/itmvc/"]
...
+++

Absolutely nothing happens to the index.html for content/pages/itmvc. I’ve tried content/pages/itmvc, my.tld/pages/itmvc, content/pages/itmvc/index.html all to no avail. My understanding would be that it would change content/pages/itmvc to a new index.html with the special tags to perform the redirect. But really nothing at all happens to either pages. Am I doing something wrong?

Thanks!

Just to add, I also checked if it was a browser cache issue by opening up the page in incognito mode, but that didn’t work either.

Thanks again!

Not sure what you doing wrong without seeing the full picture, many working examples can be found in the Hugo doc itself:



Thanks, yea I’ve checked all the github issues too to see if anyone else has had this problem but haven’t found anything. What other info would help?

I see a lot about RelativeUrl settings, but I don’t use that and am not sure what that will do to the rest of my site.

Only the full info (aka the full site on GitHub, for instance) would make me look further into this. Maybe others would like to chime in with some wild guesses.

OK, now I read what you write. Alias is not a redirect to another page feature. It is page aliasing, nothing more. It writes actual redirect files to disk.

Ok thanks.

So for the page that I listed as an alias to: /pages/itmvc/, I was thinking that the output of building the site (after adding the alias) would place a newindex.html file in the folder /public/pages/itmvc that looked like this:

<!DOCTYPE html>
<html>
  <head>
    <link rel="canonical" href="http://mysite.tld/posts/my-original-url"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta http-equiv="refresh" content="0;url=http://mysite.tld/posts/my-original-url"/>
  </head>
</html>

But instead, nothing happens at all. It’s just the same old content in that folder. It doesn’t throw any errors, but it doesn’t seem to do what I thought it would do - swap out the original content with the above index.html

I also wish I could share the whole site, but I can’t really do that as a whole since it’s in a private Github

This is probably do to the order of generation – it is a static page so the last file with a given file name will win.

Oh so it was a mistake that I named all three files the same probably?

Would there be anything wrong with just hard-coding that redirect HTML onto the original page instead of relying on Hugo to do it for me?

@heynickc I’m confused: if you named all three files the same name but want them all to lead to the newest version, why even include an alias in the first place? I don’t use .toml for my front matter, but I don’t have any issues with the following yaml front matter:

title: My New Page
date: 2016-07-23
aliases: [/my-old-page/]

When navigating to mysite.com/my-old-page/ is redirects to mysite.com/my-new-page without issue. Also, have you tried removing the old markdown files that you no longer want on the site? Seems to make more sense for search purposes as well…

Thank you, this cleared it up for me. I didn’t know you had to actually delete the old versions to have the aliases replace them. Thank you.