Documentation Index Fetch the complete documentation index at: https://mintlify.com/formsmd/formsmd/llms.txt
Use this file to discover all available pages before exploring further.
The Forms.md CLI tool converts your Markdown form templates into static HTML pages, perfect for hosting on any web server or static hosting platform.
Installation
Install Forms.md globally via npm:
Or use it with npx without installing:
px formsmd --input src --output site
Quick start
Create your forms
Create Markdown files in a source directory: mkdir src
echo "# Contact Form" > src/contact.md
Run the CLI
Generate your static site: formsmd --input src --output site
Deploy
Upload the site directory to any web host or serve it locally: cd site
python -m http.server 8000
Command options
The CLI accepts three command-line options:
Specifies where your Markdown form templates are located.
formsmd --input src
formsmd -i forms
Default: src
Output directory
Specifies where the generated HTML files will be saved.
formsmd --output site
formsmd -o build
Default: site
Static directory name
Specifies the name of your static assets folder (images, CSS, etc.).
formsmd --static-dir-name assets
formsmd -s public
Default: static
The static directory is automatically copied from input to output, preserving the folder structure.
Complete command
formsmd --input forms --output dist --static-dir-name assets
Short form:
formsmd -i forms -o dist -s assets
Directory structure
src/
├── contact.md
├── survey.md
├── application.md
├── base.html (optional)
└── static/
├── images/
│ ├── logo.svg
│ └── hero.jpg
└── styles/
└── custom.css
Output structure
After running the CLI:
site/
├── contact.html
├── survey.html
├── application.html
├── content/
│ ├── contact.md.js
│ ├── survey.md.js
│ └── application.md.js
├── formsmd/
│ ├── css/
│ │ ├── formsmd.css
│ │ ├── formsmd.min.css
│ │ └── formsmd.rtl.css
│ └── js/
│ ├── formsmd.bundle.min.js
│ └── composer.bundle.min.js
└── static/
├── images/
└── styles/
The CLI automatically includes all necessary Forms.md CSS and JavaScript files in the formsmd directory.
Create a Markdown file in your input directory:
#! title = Contact Form
#! accent = #6366f1
#! post-url = https://example.com/api/contact
# Get in Touch
We'd love to hear from you!
name* = TextInput(
| question = What is your name?
)
email* = EmailInput(
| question = What is your email address?
)
message* = TextInput(
| question = Your message
| multiline
)
URL slugification
The CLI automatically creates URL-friendly filenames:
Markdown file Generated HTML URL contact.mdcontact.html/contact.htmlAbout Us.mdabout-us.html/about-us.htmlFAQ 2024.mdfaq-2024.html/faq-2024.html
Filenames are slugified using lowercase letters, hyphens, and strict mode (removes special characters).
Custom base template
Override the default HTML template by creating a base.html file in your input directory.
Default base template
The CLI includes a base template with this structure:
<! DOCTYPE html >
< html lang = "en" dir = "{{ settings.dir }}" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > {{ settings.title }} </ title >
< link rel = "stylesheet" href = "/formsmd/css/formsmd.min.css" >
</ head >
< body >
< div id = "form" ></ div >
< script type = "module" >
import {{ route }} Template from '/content/{{ route }}.md.js' ;
import { Formsmd } from '/formsmd/js/formsmd.bundle.min.js' ;
const form = new Formsmd (
{{ route }} Template ,
document . getElementById ( 'form' ),
{ isFullPage: true }
);
form . init ();
</ script >
</ body >
</ html >
Custom template variables
Your custom base.html can use these Nunjucks variables:
Variable Description Example {{ route }}URL-friendly page name contact{{ settings.title }}Page title from #! title Contact Form{{ settings.dir }}Text direction ltr or rtl{{ settings.* }}Any setting from your template {{ settings.accent }}
Example custom template
<! DOCTYPE html >
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > {{ settings.title }} - My Company </ title >
< link rel = "stylesheet" href = "/formsmd/css/formsmd.min.css" >
< link rel = "stylesheet" href = "/static/styles/custom.css" >
< link rel = "icon" href = "/static/images/favicon.ico" >
</ head >
< body >
< nav >
< a href = "/" > Home </ a >
< a href = "/contact.html" > Contact </ a >
< a href = "/survey.html" > Survey </ a >
</ nav >
< div id = "form-container" ></ div >
< footer >
< p > © 2024 My Company </ p >
</ footer >
< script type = "module" >
import {{ route }} Template from '/content/{{ route }}.md.js' ;
import { Formsmd } from '/formsmd/js/formsmd.bundle.min.js' ;
const form = new Formsmd (
{{ route }} Template ,
document . getElementById ( 'form-container' ),
{
isFullPage: false ,
paddingInlineTop: 40 ,
paddingInlineBottom: 40
}
);
form . init ();
</ script >
</ body >
</ html >
Static assets
The CLI automatically copies your static assets directory.
Organizing assets
src/
├── contact.md
└── static/
├── images/
│ ├── logo.svg
│ ├── hero.jpg
│ └── favicon.ico
├── styles/
│ └── custom.css
├── scripts/
│ └── analytics.js
└── fonts/
└── custom-font.woff2
#! background-image = url('/static/images/hero.jpg')
#! brand = 
#! favicon = /static/images/favicon.ico
Use absolute paths starting with /static/ to reference your assets.
RTL support
The CLI automatically includes RTL stylesheets:
#! localization = ar
#! dir = rtl
This loads formsmd.rtl.css instead of the standard stylesheet.
Development workflow
Watch mode (manual)
With live server
Package.json scripts
Use a file watcher to rebuild on changes: npm install -g nodemon
nodemon --watch src --ext md,html --exec "formsmd -i src -o site"
Combine with a live server for auto-reload: # Terminal 1: Watch and rebuild
nodemon --watch src --ext md,html --exec "formsmd -i src -o site"
# Terminal 2: Serve with live reload
cd site
npx live-server
Add scripts to your package.json: {
"scripts" : {
"build" : "formsmd -i src -o site" ,
"watch" : "nodemon --watch src --ext md,html --exec npm run build" ,
"serve" : "cd site && npx live-server" ,
"dev" : "npm run watch & npm run serve"
}
}
Then run:
Deployment
Deploy your generated site to any static hosting platform:
Netlify
Vercel
GitHub Pages
AWS S3
# Install Netlify CLI
npm install -g netlify-cli
# Build and deploy
formsmd -i src -o site
netlify deploy --prod --dir=site
Build optimization
The CLI automatically optimizes the output:
Minified CSS (formsmd.min.css)
Minified JavaScript bundles
Escaped backticks in templates
Slugified URLs
Organized file structure
Additional optimization tips
Compress images before placing in static/
Enable gzip on your web server
Set cache headers for static assets
Use a CDN for the formsmd directory
Lazy load images in your forms
Manage multiple forms in one project:
formsmd -i forms -o public
forms/
├── contact.md
├── newsletter.md
├── job-application.md
├── customer-survey.md
└── static/
└── images/
Generates:
public/
├── contact.html
├── newsletter.html
├── job-application.html
├── customer-survey.html
└── ...
Troubleshooting
If formsmd command is not found: # Check if globally installed
npm list -g formsmd
# Reinstall globally
npm install -g formsmd
# Or use npx
npx formsmd -i src -o site
Output directory not created
The CLI creates the output directory automatically. If it fails: # Check write permissions
ls -la
# Manually create directory
mkdir site
# Run CLI again
formsmd -i src -o site
Ensure your static directory name matches the CLI flag: # If your folder is named 'assets'
formsmd -i src -o site -s assets
# Check directory structure
tree src
Next steps
Form inputs Learn about all available input types
Google Sheets Save responses to Google Sheets