Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Set Up a Static Site with Gatsby

Gatsby builds React static sites. On a VPS you compile once and serve HTML/JS/CSS with Nginx.

Steps

  1. Ensure Node.js LTS and the Gatsby CLI:

    node -v || (curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt install -y nodejs)
    sudo npm install -g gatsby-cli
    gatsby --version
  2. Scaffold the project and run a production build:

    cd ~ && npx gatsby new my-gatsby
    cd ~/my-gatsby
    npm run build
  3. Publish public/ with Nginx:

    sudo mkdir -p /var/www/my-gatsby
    sudo rsync -a ~/my-gatsby/public/ /var/www/my-gatsby/
    sudo tee /etc/nginx/sites-available/my-gatsby >/dev/null <<'EOF'server {  listen 80;  server_name example.com;  root /var/www/my-gatsby;  index index.html;  try_files $uri $uri/ /index.html;}EOF
    sudo ln -sf /etc/nginx/sites-available/my-gatsby /etc/nginx/sites-enabled/my-gatsby
    sudo nginx -t && sudo systemctl reload nginx
  4. After content changes, rebuild and sync:

    cd ~/my-gatsby && npm run build
    sudo rsync -a ~/my-gatsby/public/ /var/www/my-gatsby/

Tips

  • Gatsby builds want RAM: ≥2 GB VPS helps.
  • Do not expose gatsby develop to the internet — only the static build.

ext step

More RAM for static builds: Deploy your Cloud VPS.

Related guides