0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Gatsby.jsのサイトにNetlifyのformsを導入する

Posted at

シンプルなお問い合わせフォームをGatsby.jsの静的サイトに導入してみました。

<form
  name="contact"
  method="post"
  data-netlify-honeypot="bot-field"
  data-netlify="true"
  autocomplete="off"
  action="/thanks"
>
  <input type="hidden" name="form-name" value="contact" />
  <p hidden>
    <label>
      Don’t fill this out if you're human:
      <input name="bot-field" />
    </label>
  </p>
  <div>
    <label>名前</label>
    <input id="name" type="text" name="name" />
  </div>
  <div>
    <label>メール</label>
    <input id="email" type="email" name="email" />
  </div>
  <div>
    <label>メッセージ</label>
    <textarea id="message" name="message"></textarea>
  </div>
  <div>
    <button type="submit">送信</button>
  </div>
</form>

formタグの中にaction="/path-to-thanks-page"と記載することで、送信ボタンを押したあと自動的に用意したページに遷移することが出来ます。

これだけで簡単にフォームが生成できるのすごいですね。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?