Written by: Geoffrey Callaghan
create a contact form with VuePress
Create A Contact Form With Vuepress
To create a contact form in a VuePress site using FabForm, follow these steps. VuePress is a static site generator powered by Vue.js, and FabForm is a service for handling form submissions.
Set Up VuePress Project:
npm install -g vuepress
mkdir my-docs
cd my-docs
npm init -y
npm install -D vuepress
mkdir docs
echo '# My Documentation' > docs/README.md
Create a Contact Page:
contact.md
in your docs
directory:
# Contact Us
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
Configure FabForm:
Update Sidebar Navigation:
.vuepress/config.js
to include the contact page:
module.exports = {
themeConfig: {
sidebar: [
'/',
'/contact'
]
}
}
Run Your VuePress Site:
npx vuepress dev docs
http://localhost:8080/contact.html
to ensure your contact form appears correctly and can submit data.Deploy Your Site:
npx vuepress build docs
my-docs/
├── docs/
│ ├── .vuepress/
│ │ ├── config.js
│ ├── README.md
│ ├── contact.md
├── package.json
.vuepress/config.js
:module.exports = {
title: 'My Documentation',
description: 'Documentation for my project',
themeConfig: {
sidebar: [
'/',
'/contact'
]
}
}
contact.md
:# Contact Us
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
README.md
:# My Documentation
Welcome to my documentation site.
* [Home](/)
* [Contact](/contact)
By following these steps, you will have a fully functional contact form on your VuePress site that integrates with FabForm for handling submissions.