Hugo aliases vs. Netlify redirect

Hello,

We are reimplementing our project site, migrating from CMS to Hugo. I have questions on page redirection.

Note: We will serve the website using Netlify.

If we have a URL from the legacy site that should be redirected to a new URL, tests show that both Hugo aliases and Netlify redirect work.

The questions are as follows:

  1. What’s the advantage of using server-side redirect (Netlify redirect) over client-side redirect (Hugo aliases)?
  2. What’s the advantage of Hugo aliases over Netlify redirect?
  3. Is it possible to mix Hugo aliases and Netlify redirect on the same project? Or, is it preferable to use only one of them?
1 Like

Just for clarity, Hugo aliases just work for whatever domain the site is on, not to redirect to another domain entirely.

Using Hugo aliases means you have the redirects in the project, and they are not dependent on the Netlify setup, should you ever host elsewhere.

Another negative I can think of is, if you mix them, troubleshooting becomes harder because you might forget how it is set up in 6 months.

4 Likes

Netlify redirects are redirects via header, Hugo redirects load the page first, then the page redirects. So you should always use Netlify redirects if you can, they will save some milliseconds.

4 Likes

Thank you all for the answers.

We will use the same domain with different sitemap, so using Hugo aliases seems allowable. But the performance advantage definitely prevails, so we’ll stick to Netlify redirect based upon the above explanation.

(Netlify or e.g. .htaccess) header redirects are probably much better for SEO, too, and more flexible.

2 Likes

My 50 cents;

  • For the Hugo docs site we use Netlify redirects. I added it mainly to test/demonstrate Hugo Output Formats, but 301 (aka Netlify) redirects should be more SEO friendly. Don’t ask me details …
  • If you want to mix you would typically need to add some other page param for the Netlify redirects and generate the _redirect file from that.
  • The advantage of Hugo aliases is that they are easier to test outside of Netlify, but you can probably get that by a custom develpoment config.
4 Likes

Make that ‘definitely better for SEO’. :slight_smile:

Here’s what Google says about the redirects that Hugo aliases uses:

This (…) sends the user to a new URL after a certain amount of time, and is sometimes used as a simple form of redirection. However, it is not supported by all browsers and can be confusing to the user. The W3C recommends that this tag not be used. We recommend using a server-side 301 redirect instead.

1 Like