将 FormSpree 集成到 GitHub Jekyll 中(Returns 消息:Form 应该 post)

Integrating FormSpree into GitHub Jekyll (Returns message: Form should post)

我希望在 GitHub Jekyll 网站上添加联系表格。我大部分时间都在听从最受欢迎的答案 here, from a YouTube tutorial here, and from the FormSpree site.

的建议

我创建了一个 FormSpree 帐户,验证了我的电子邮件地址,并创建了一个表单(获得了一个 ID)。然后,我尝试在我的 GitHub Jekyll 网站中添加一个联系表单,其代码可以看到 here. After that, I went to the corresponding site of that code (here) 并发送了一个测试表单提交。在电子邮件地址字段中,我尝试了连接到 FormSpree 的电子邮件地址和备用电子邮件地址。

无论哪种方式,在提交页面底部的 "Send" 按钮后,页面都会刷新并显示一条错误消息:"Form should POST - Make sure your form has the method=POST attribute"。我也没有在连接到 FormSpree 的电子邮件中收到经过测试的消息。我试图研究这个错误,但没有找到解决方案。从代码 (here) 中可以看出,我相信我 do 设置了一个 method=POST 属性。

鉴于我无法有效地解释错误消息,我不确定如何继续。非常感谢任何有关如何使此类联系表单成功的建议,尤其是在出现此错误消息的情况下!

您的 HTML 有误:

<form action="https://formspree.io/email@gmail.com method="POST" name="sentMessage" id="contactForm" novalidate>

您的操作缺少结束双引号 ("),这会导致将您的 action 属性错误解释为 "https://formspree.io/email@gmail.com method=",并将您的实际方法错误解释为无效属性 post".

应该通过将上面的行替换为

来修复
<form action="https://formspree.io/email@gmail.com" method="POST" name="sentMessage" id="contactForm" novalidate>

在你的页面源代码中这样做,我能够提交表单并登陆 FormSpree 登录页面,表明你的表单需要被激活。