Getting Started
This guide walks you through setting up Freestruct. If you hit any snags, the FAQ might help.
TL;DR
# 1. Install (the freestruct npm package)
npm install --save-dev freestruct
# 2. Build your site (your SSG, any flavor)
jekyll build # or hugo, docusaurus build, etc
# 3. Inject SEO
npx freestruct
# 4. Deploy
# That's it. Every page now has perfect SEO.
Prerequisites
- Node.js 20+ - Run
node --versionto check (Freestruct is ESM and requires Node 20 or newer) - A static site generator - Jekyll, Hugo, Docusaurus, anything
- Terminal access - Command line, not GUI
Don’t have Node? Install it from nodejs.org or via homebrew: brew install node.
Step 1: Install Freestruct
npm install --save-dev freestruct
That’s it. The npm package ships everything it needs at runtime, including its one dependency (js-yaml) - npm installs it automatically with the package. You only install dependencies by hand when running the engine from a repo checkout.
Step 2: Create Your Config
Create docs/freestruct.config.yml with this minimum setup:
# Where your SSG outputs files
outputDir: _site # Jekyll
# outputDir: public # Hugo
# outputDir: build # Docusaurus
# Your site info - shows up in search results + social
site:
url: https://yoursite.com
name: Your Site Name
description: What your site does (this shows in Google)
# Optional: Twitter card info
twitter:
username: "@yourhandle"
card: summary # summary, summary_large_image, app, or player
# Optional: Open Graph image
og:
image: /assets/og-image.png
Don’t skip the description - it’s what people see in Google results.
Step 3: Run Freestruct
After your SSG builds:
# Full build for Jekyll
jekyll build && npx freestruct
For other SSGs, just swap the build command:
# Hugo
hugo && npx freestruct public
# Docusaurus
docusaurus build && npx freestruct build
# MkDocs
mkdocs build && npx freestruct site
# VitePress
vitepress build && npx freestruct .vitepress/dist
Step 4: Verify It Works
Open any generated HTML file. You should see in the <head>:
<meta name="description" content="What your site does">
<link rel="canonical" href="https://yoursite.com/">
<meta property="og:title" content="Page Title | Your Site Name">
<meta name="twitter:card" content="summary">
<meta name="freestruct-build" content="abc123">
The canonical carries a ?v=abc123 query param only when you set cacheBusting.hashInCanonicalUrl: true (off by default).
If you see those tags, you’re ready to ship.
Step 5: Automate with CI/CD
Add this to your GitHub Actions workflow:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install freestruct
run: npm install --save-dev freestruct
- name: Build site + inject SEO
run: |
jekyll build
npx freestruct
Or add to your package.json:
{
"scripts": {
"build": "jekyll build && npx freestruct"
}
}
What If It Doesn’t Work?
- Run
npx freestruct audit- it verifies the baked output page by page (missing titles, descriptions, canonicals, the 404 noindex contract, sitemap/robots) and names every gap;--jsongives you the machine digest - Check the hash - View page source, look for
freestruct-build - Verify outputDir - Does it match your SSG’s output folder?
- Check config - Run
cat docs/freestruct.config.ymland verifysite.nameandsite.urlon first run; Freestruct prints[freestruct] config warninglines for any key it does not recognize - See the FAQ - We documented every weird edge case
Related
- Configuration - All available options
- CLI Reference - Every command, flag and exit code
- Cache Busting Guide - Why the hash matters
- FAQ - Pain points and solutions
- CI/CD Recipes - Automating the deploy pipeline
- Troubleshooting - When a step fails