Contact form
Ananke includes a form-contact shortcode that renders a ready-styled contact
form you can drop into any page.
What it outputs #
The shortcode outputs an HTML <form> with name, email, and message fields and a submit button, styled to match the theme. Each field uses a native label. The email field also announces the email requirement as its accessible description. It submits with POST to the address you give in the action parameter.
The fields and browser validation work without JavaScript. Name and email are required; the email field checks the email format. Your form backend must also validate submitted values.
Required configuration #
The action parameter is required — it is the URL that receives the submitted form. Ananke does not check it: without action, the form renders, prints no build warning, and sends the data back to the page itself.
{{< form-contact action="https://formspree.io/your@email.com" >}}Use any service that accepts an HTML form POST. Formspree
is a common choice and offers a free tier; sign up, create a form, and use the
action URL it gives you.
Form fields #
The generated form contains:
- Your Name — a required text input (
name). - Email Address — a required email input (
email). - Message — a multi-line text area (
message). - a Send submit button.
All labels are translatable interface strings, so they appear in the visitor’s language (see Multilingual and i18n).
A complete contact page #
+++
title = "Contact"
+++
Please use the form below to contact us.
{{< form-contact action="https://formspree.io/your@email.com" >}}Using a form backend #
The form is a plain HTML form, so it works with any endpoint that accepts a
POST:
- Formspree — paste the action URL as shown above.
- Netlify Forms — Netlify needs a
data-netlify="true"attribute and a hidden form-name field on the<form>. The built-in shortcode does not add these, so for Netlify Forms copy the shortcode into your project atlayouts/_shortcodes/form-contact.htmland add the required attributes. See Overriding partials for the override pattern.
Spam protection #
The shortcode does not include built-in spam protection (no CAPTCHA or honeypot). Rely on your form backend’s spam filtering (Formspree and Netlify both provide it), or add a honeypot field in an overridden copy of the shortcode.
Customising labels #
The field labels come from the theme’s i18n strings:
| Key | Used for |
|---|---|
yourName | The label of the name field. |
emailAddress | The label of the email field. |
emailRequiredNote | The note below the email field. |
message | The label of the message field. |
send | The text of the submit button. |
Override them in your project’s i18n/<language>.toml rather than
editing the shortcode — see
Overriding theme interface strings.
Limitations #
- The fields are fixed (name, email, message). To add or remove fields, override
the shortcode in your own
layouts/_shortcodes/form-contact.html. - The fields have fixed
idvalues (name,email,message). Use the shortcode only once per page, because two forms would repeat these IDs and break the label links. - The shortcode renders the form only; it does not send email itself. You must
provide a backend via
action.