Skip to main content
NostalgiaPHP
Home
About
  • Components
  • Blink
  • Fetch
  • Slider
  • REST API
BlogDoxSearchContact
Admin
  • Sitemap
  • Robots
GitHub
  1. Home
  2. Dox
  3. Nosty CLI — Your New Best Friend
Sep 28, 2025

NostalgiaPHP CLI

A tiny command-line helper for working with NostalgiaPHP sites.

The CLI lives in the project root (nphp). Run it with PHP:

php nphp <command> [args]

Commands

make:post

Scaffold a new post in a collection.

php nphp make:post <collection> <slug> [options]

Options:

  • --title="Custom Title" → Override default title
  • --template=main → Which front‑matter template (default: main)
  • --date=YYYY-MM-DD → Override date (default: today in site timezone)
  • --draft → Add draft: true to front matter
  • --force → Overwrite if file already exists

Example:

php nphp make:post blog hello-world --title="Hello World" --draft

make:page

Scaffold a new standalone page.

php nphp make:page <slug> [options]

Same options as make:post.

Example:

php nphp make:page about --title="About Us"

backup

Zip up your entire project into a timestamped archive.

php nphp backup [--to=/absolute/path]

If no --to is provided, backups go to ~/nosty_backups/<project>.

Example:

php nphp backup --to="$HOME/Dropbox/nosty_backups"

Build (SSG)

Pre-render your site into static HTML (Static Site Generation).

This command:

  • Copies static/ into the output directory
  • Each page is written to disk as {dir}/index.html so that users see clean URLs like /about instead of /about.html.
  • Renders all collections (lists + individual items, with pagination)
  • Fixes relative asset paths for portability
  • Pre-renders dynamic routes like:
    • /tags (list of all tags)
    • /tag/{slug} (all items/pages for a tag)
    • /sitemap.xml (auto-generated sitemap for search engines)
    • /robots.txt (with a link to the sitemap)

⚠️ Limitations: Some pages cannot be safely pre-rendered. For example, the Contact page contains a live form that posts back to the same PHP route. Pre-rendering would freeze it into a static file, breaking submissions. To support forms on static hosting, you’d need to switch to a client-side submission method (JavaScript + API endpoint or a service like Netlify Forms).

php nphp build [--out=dist] [--clean]

Options:

  • --out=dist → Output directory (default: dist)
  • --clean → Remove existing output directory before building

Examples:

# Build into /dist
php nphp build

# Clean old build and output to /public
php nphp build --out=public --clean

Why It Matters

The CLI helps you:

  • Scaffold content quickly (posts, pages)
  • Back up your entire project
  • Pre-render your site for static hosting

With build, you can host your NostalgiaPHP site anywhere — Netlify, GitHub Pages, Vercel, S3 — no PHP server required.

Explore

Recent Items

  • You Might Not Want to Use NostalgiaPHP
    Oct 8, 2025
  • Understanding the Styles
    Oct 5, 2025
  • Appear Animations
    Oct 2, 2025
  • Nosty CLI — Your New Best Friend
    Sep 28, 2025
  • Introducing the NostalgiaPHP REST API
    Sep 27, 2025

Tags

  • animation (1)
  • api (1)
  • blink (1)
  • css (1)
  • intersectionobserver (1)
  • js (1)
  • json (1)
  • nostalgia (2)
  • php (3)
  • reactivity (1)
  • rest (1)
  • retro (3)
  • simplicity (3)
  • slank (1)
© 2025 NostalgiaPHP. All rights reserved. ⬆ Back to Top