Form ID

Jekyll

A Jekyll include that renders an Ikiform form from _config.yml, with redirects that work on GitHub Pages and custom domains.

Jekyll sites are static, which suits a plain form post. Keep the form in an include so every page uses the same markup and the form id lives in one place.

Set it up

  1. Add the settings to _config.yml

    _config.yml
    url: "https://example.com"
    ikiform:
      form_id: frm_xxxxxxxxxxxxxxxx
      thanks: /thanks/

    The include builds the redirect with absolute_url, which needs url. Without it, the redirect is only a path, and Ikiform ignores anything that isn't a full https: URL. On a GitHub Pages project site, also set baseurl: /repo; absolute_url adds it for you.

  2. Create the include

    _includes/ikiform-form.html
    {%- assign form_id = include.form_id | default: site.ikiform.form_id -%}
    {%- assign thanks = include.thanks | default: site.ikiform.thanks -%}
    <form class="ikiform" action="https://ikiform.com/f/{{ form_id }}" method="post">
      <label>Email <input name="email" type="email" autocomplete="email" required></label>
      <label>Message <textarea name="message" rows="5"></textarea></label>
      {%- if include.subject %}
      <input type="hidden" name="_subject" value="{{ include.subject | escape }}">
      {%- endif %}
      {%- if thanks %}
      <input type="hidden" name="_redirect" value="{{ thanks | absolute_url }}">
      {%- endif %}
      <input name="_gotcha" type="text" tabindex="-1" autocomplete="off" hidden>
      <button type="submit">{{ include.button | default: "Send" }}</button>
    </form>
  3. Use it

    contact.md
    ---
    layout: page
    title: Contact
    ---
    
    Questions about pricing? Write to us.
    
    {% include ikiform-form.html subject="Pricing question" %}

    The include works in pages, posts and layouts. Pass form_id to use another form, thanks for another redirect, and button for the button text.

  4. Add the thank-you page

    thanks.md
    ---
    layout: page
    title: Thanks
    permalink: /thanks/
    ---
    
    Thanks, we got your message.

_redirect is followed only when the form has allowed domains that include your site. See Rules for _redirect.

Allowed domains

GitHub Pages is the usual host for Jekyll, so you'll often need two entries: the github.io host and your custom domain.

Where the form runsAdd to Allowed domains
bundle exec jekyll servelocalhost. It matches http://localhost:4000: Ikiform compares the host name only, never the port.
GitHub Pagesusername.github.io. Project sites at username.github.io/repo use the same host, so one entry covers them all.
Custom domain on GitHub Pagesexample.com, which also covers www.example.com
Netlifyyour-site.netlify.app. Deploy previews (deploy-preview-12--your-site.netlify.app) and branch deploys (branch--your-site.netlify.app) are not subdomains of it, so add the exact preview host while you test one.
  • Never add github.io on its own. Every site on that host would match, including other people's.

Test checklist

  1. Run bundle exec jekyll serve and view the page source. The action should end in your form id.
  2. Submit locally. You'll land on Ikiform's thank-you page: jekyll serve sets url to http://localhost:4000, and http: redirects aren't followed.
  3. Push, wait for the Pages build, and submit from username.github.io. Confirm the submission isn't marked spam.
  4. Submit on your custom domain and confirm you land on /thanks/.

Troubleshooting

What you seeWhyFix
Could not locate the included file 'ikiform-form.html'The file isn't in _includes, or the name differsMove it to _includes/ikiform-form.html.
Ikiform's thank-you page instead of /thanks/ on the live siteurl is missing from _config.yml, or the form has no allowed domainsSet url to your https: address and add your domain.
404 not_found after submitsite.ikiform.form_id is empty, so the action ends in /f/Check the indentation under ikiform: in _config.yml.
Submissions arrive under the spam filter with origin_mismatchThe page that posted isn't on the form's allowed domainsAdd the host from the table above. With Reject chosen, the same posts get 403 origin_not_allowed instead.