How to return 301 Moved Permanently?

Hi guys,

I have reworked my wife’s website and re-imported data from another location. This will result in old product pages having 404 Not Found unless I manually redirect each page.

Is there a good way to do that in hugo that will work for Google indexing engine?

I don’t have access to the web server, because I host the static website on Google Storage bucket.

Am I totally out of luck in terms of implementing a proper 301 redirect?

You can use Hugo aliases to do page redirects, but to do this at the HTTP layer, you need a better host service (such as Netlify).

I think you want to read about aliases:

Other than that, Stackoverflow.com has quite some answers about “Google Storage Buckets” and redirects. There seems to be a way via app.yaml - but this is out of the scope of Hugo.

No, you are in luck. No go and setting it up easily in that storage service, but the good news is moving it elsewhere is super easy. There are tons of cheap and free hosting and has proper redirect systems. :slight_smile:

We do that on the Hugo web sites with Netlify redirects: https://github.com/gohugoio/hugoDocs

In short:

  • Disable aliases
  • Use the same alias definitions to create a Netlify redirects file with a Custom Output Format
1 Like

Thank you guys. It gives me enough pointers.

I suggest you also see the following link if you go the aliases route: