Hugo alias and parameters


I have a hugo url as follows /en/id/verify-email?code=TOKEN

The verify-email.html file as an alias

However when I get a request in for /id/verify-email?code=TOKEN this needs to redirect to /en/id/verify-email?code=TOKEN but the params are being stripped off on the redirect

Is there anyway in Hugo to handle this?

Thanks in advance

You need to write your own alias template.

Thanks for the reply @bep - I will digg into this more so, BUT may be back :slight_smile:

Hi @bep I have a custom alias template but not sure how to grab the parameters code and its value token? so I can do the redirect with them in the URL.

This might be helpful:

1 Like

Thanks, thats a bit more elegant than what I came up with

<!DOCTYPE html>
    <title>{{ .Permalink }}</title>
    <link rel="canonical" href="{{ .Permalink }}">
    <meta name="robots" content="noindex">
    <meta charset="utf-8" />
    <meta http-equiv="refresh" content="0; url={{ .Permalink }}" id="meta-tag" />
  <script type="text/javascript">
    var url = document.querySelector('meta[id="meta-tag"]').getAttribute("content");
    document.querySelector('meta[id="meta-tag"]').setAttribute("content", url +;

Really appreciate your help @bep :+1:

1 Like

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