Feedback & forms
The helpful vote at the foot of every page, and how to collect anything else from readers.
The helpful vote
Every documentation page ends with “Was this page helpful?”. It is a real <form method="post">, so it works with JavaScript disabled — a script upgrades it to submit in the background and swap in the thank-you message without a page load. The reader never leaves the page, so the vote has no success page.
Turn it off per page with showFeedback: false in frontmatter, or site-wide in src/data/pageTools.json.
Where the vote goes
The vote’s settings live under feedback in src/data/pageTools.json. What you set there depends on where the votes go:
- CloudCannon Forms (the default, and only if CloudCannon hosts the site): keep
inboxKeyasstratus-form, the Inbox every form on this site uses. Setactionto any page on this site, or leave it empty to post to the page the reader voted on. With JavaScript on, the reader stays on the page either way. With it off, CloudCannon sends them to theactionpage, so empty brings them back to where they voted. First create the Inbox and link it to the site — see Setting up CloudCannon Forms below. Until you do, votes have nowhere to go. - Any other endpoint: set
actionto the endpoint’s URL, and deleteinboxKeyso the field isn’t sent.
{
"feedback": {
"enabled": true,
"action": "",
"inboxKey": "stratus-form"
}
}{
"feedback": {
"enabled": true,
"action": "https://formspree.io/f/YOUR_ID"
}
}{
"feedback": {
"enabled": true,
"action": ""
}
}
// Netlify needs the form to declare itself; the block already
// posts a `form-name` field, so add data-netlify="true" in
// navigation/page-feedback/PageFeedback.astro.{
"feedback": {
"enabled": true,
"action": "https://api.acme.com/docs-feedback"
}
}Every endpoint receives the same three fields, posted as multipart/form-data. With inboxKey set, the vote sends a fourth field, inbox_key:
form-namestringrequiredAlways
page-feedback, so one endpoint can serve several forms.pagestringrequiredThe path of the page that was voted on, e.g.
/theming/.votestringrequiredyesorno.inbox_keystringThe value of
feedback.inboxKey. Sent only when it is set.
A cross-origin endpoint needs CORS
The upgraded submit uses fetch, so an endpoint on another domain must send Access-Control-Allow-Origin. Without it the vote is silently dropped — deliberately: a reader who clicked Yes should never be shown an error.
Setting up CloudCannon Forms
CloudCannon Forms needs CloudCannon hosting
Forms only receive submissions on a site that CloudCannon hosts. If you deploy somewhere else, or use CloudCannon in Headless Mode, use another form service instead — see Any other form.
Setting it up takes two steps, both in the CloudCannon app, and no code.
Create an Inbox
In your Organization settings, open Hosting › Forms and click Add Inbox. Name it, set its key to
stratus-form, and optionally add a CAPTCHA provider. An Inbox belongs to the organization, so several sites can share one.Link it to this site
In the site's settings, open Hosting › Forms, choose the Inbox under Link Inbox, and click Link Inbox. Forms on the site can now send submissions to it.
Decide where submissions go next
Read them in the Inbox, or forward them by email or to Slack, Zapier, Make or IFTTT from the Inbox's settings.
Every form on this site includes a hidden field that names the stratus-form Inbox: <input type="hidden" name="inbox_key" value="stratus-form">. The helpful vote adds it from feedback.inboxKey. In a Form block, add it as a Hidden field with name set to inbox_key and value set to stratus-form.
A CloudCannon form’s action is the page the visitor is sent to after submitting. It must be a page on this site, but it doesn’t have to be / — point it at a thank-you page, or back at the form’s own page with ?success on the end to show the form’s successMessage. CloudCannon’s guides cover the details: creating an Inbox and connecting a site to one.
To filter spam, set the form’s honeypotName to _gotcha. That adds a field people never see; CloudCannon discards any submission where a bot filled it in. For more protection, add a CAPTCHA provider in the Inbox’s settings.
Inboxes have a monthly limit
Each Inbox accepts 2,250 submissions a month. Every form on this site shares the stratus-form Inbox, and the helpful vote on every page counts toward it — a busy docs site can reach that.
Any other form
Forms are built from the same blocks as the rest of the site, and can be dropped into a documentation page. On a CloudCannon-hosted site with a linked Inbox, a form collects submissions with no backend.
A form needs somewhere to send submissions
The Form component only builds the HTML form. It does not store or send anything. Before you publish one, choose where its submissions go.
There are two ways to set that up:
- Use CloudCannon Forms. This works only if CloudCannon hosts your site. First, follow Setting up CloudCannon Forms to create an Inbox and link it to your site. CloudCannon’s Forms documentation has the full reference. Then, in the form itself:
- Set
actionto the page on this site to send the visitor to after they submit. The form below uses a thank-you page,/form-success/. You can also send them back to the form’s own page with?successon the end, as described below. - Give every field a
name. - Leave
methodset toPOST. - Set
honeypotNameto_gotcha. - Add a Hidden field with
nameset toinbox_keyandvalueset tostratus-form.
- Set
- Use another form service. Formspree, Basin, Netlify Forms and your own API all work, and so does any host. You can paste the service’s own embed code into an
Embedblock, as described in Media & components, or keep using this form:- Set
actionto the endpoint URL the service gives you. - Give every field the
namethe service expects. - Set
honeypotNameto the service’s spam field, if it has one.
- Set
With either option, you can set successMessage to show a confirmation after someone submits the form. The message appears only when the visitor comes back to the form’s page with ?success on the end of the URL. With CloudCannon Forms, set action to that address. With another service, set the service’s redirect to it.
Validation is the browser's, with better messages
Fields marked required are validated natively; a script replaces the browser's tooltip with an inline message under each field, and focuses the first one that failed.