Hugo
A Hugo partial that renders a native HTML form. It needs no JavaScript: FormRoost answers the post with a redirect to your own thank-you or error page. Hosts and IDs below are placeholders.
Configure the form
In the form's sandbox draft:
- Add your dev origin, such as
http://localhost:1313, to Allowed origins. - Set Success redirect to an absolute URL such as
http://localhost:1313/thanks/. - Set Error redirect to an absolute URL such as
http://localhost:1313/contact/error/.
On success FormRoost answers 303 to the success redirect. On a rejected submission it answers 303 to the error redirect with the problem code appended, for example ?error=submission_schema_invalid. Without redirects, visitors see a FormRoost result page instead.
Site config
Partial
Use it from any template with {{ partial "formroost-form.html" . }}, or wrap it in a shortcode for Markdown content.
Error page
The error page can explain the code. Codes are stable; see errors.
Optional progressive enhancement
This script keeps visitors on the page, sends JSON with credentials: 'omit', and adds _fr_started_at as a number so minimum-completion timing can apply. Without JavaScript the native post still works.
Go to production
Add your live HTTPS origin, set the redirects to your live URLs, and publish. Then change sandbox to production in hugo.toml. See browser submissions and configuration and publish.