Netlify form not redirecting to custom `/thank-you/ ` page (HUGO)

I’m working on a site (https://clear-choiceglass.com) built with Hugo. I want the contact form to redirect to a static /thank-you/ page after submission.

Here’s the form:

    <form id="contact" class="[ grid gap--1 ]" name="contact" action="/thank-you/" method="POST" data-netlify="true" netlify-honeypot="bot-field" data-netlify-recaptcha="true" data-validate>
      <input type="hidden" name="form-name" value="contact" />

      <div class="hidden">
        <label>
          Don't fill this out if you're human: <input name="bot-field" />
        </label>
      </div>
      
      <div class="[ form__field ][ grid row-gap--0.5 ]">
        <label class="[ form__label ][ font--500 font--600 ]" for="name">Name <abbr class="[ required ]" title="This field is required" aria-label="This field is required">*</abbr></label>
        <input class="[ form__input ][ p--0.5 ]" name="name" id="name" type="text" placeholder="Your Name" required minlength="2" maxlength="50"/>
      </div>
      <div class="[ form__field ][ grid row-gap--0.5 ]">
        <label class="[ form__label ][ font--500 font--600 ]" for="email">Email <abbr class="[ required ]" title="This field is required" aria-label="This field is required">*</abbr></label>
        <input class="[ form__input ][ p--0.5 ]" name="email" id="email" type="email" placeholder="your@email.com" required/>
      </div>
      <div class="[ form__field ][ grid row-gap--0.5 ]">
        <label class="[ form__label ][ font--500 font--600 ]" for="message">Message <abbr class="[ required ]" title="This field is required" aria-label="This field is required">*</abbr></label>
        <textarea class="[ form__message ][ p--0.5 ]" name="message" id="message" placeholder="Tell us how we can help..." required maxlength="3000"></textarea>
      </div>
      <div data-netlify-recaptcha="true"></div>
      <div class="[ flex end ]">
        <button type="submit" class="[ btn btn--lg aac--black ]">Send</button>
      </div>
    </form>
  • The /thank-you/ page exists in the Hugo build at /public/thank-you/index.html.
  • I’ve never had issues with this setup before.
  • But when I submit the form, I either get:
    • A 404 error, or
    • Netlify’s default form success page, not my custom /thank-you/.
  • I also have an event function (submission-created.js ) which I’ve tried the build with and without, so that doesn’t seem to be the problem either.
  • I have also already tried a deploy without cache , but the issue persists.

From what I can tell, everything is in order — but it seems like Netlify isn’t serving my custom page.

Does something about the Hugo build or Netlify setup prevent the redirect from finding my page?

So, the redirect was compromised by absolute urls generated by the build. canonifyURLs = true was the culprit.

The path must be relative, for Netlify’s redirect to work.

2 Likes