Type something to search...

Astrolock build

astrolock build

astrolock build

Builds your site for production deployment, creating optimized static files ready to host.

Usage

astrolock build

What It Does

The build command:

  1. Validates configuration - Checks .astrolock/astrolock.yaml
  2. Processes content - Converts markdown to HTML
  3. Generates pages - Creates all routes and pagination
  4. Optimizes assets - Compresses images, minifies CSS/JS
  5. Creates search index - Generates .json/search.json
  6. Builds sitemap - Creates sitemap.xml
  7. Outputs to dist/ - Final static site ready to deploy
$ astrolock build

Building Astrolock site for production...

 Validating configuration
 Processing 25 content files
 Generating 48 pages
 Optimizing 12 images
 Building search index
 Creating sitemap

Build completed in 8.2s

Output: dist/
Size: 4.2 MB
Pages: 48
Assets: 23

Ready to deploy!

All files are output to the dist/ directory:

dist/
├── index.html              # Homepage
├── blog/
   ├── index.html         # Blog listing
   ├── my-post/
   └── index.html     # Post page
   ├── page/2/            # Pagination
   ├── categories/
   └── tags/
├── media/mixes/
   ├── index.html         # Collection listing
   └── summer-mix/
├── about/index.html       # Static page
├── assets/                # CSS, JS, fonts
├── audio/                 # Copied from public/
├── images/                # Copied from public/
├── video/                 # Copied from public/
├── sitemap.xml
├── robots.txt
└── .json/search.json      # Search index

When to Build

Build your site when:

  • Ready to deploy: After finishing content changes
  • Testing production: Verify everything works
  • Before deploying: Always build fresh before deployment

Build vs Development

Featurebuild (Production)write (Development)
SpeedSlower (8-15s)Faster (3-5s)
OptimizationFullMinimal
MinificationYesNo
Image optimizationYesNo
Hot reloadNoYes

Tip

Use write while developing, build when deploying.

Images

  • Converts to modern formats (WebP, AVIF)
  • Generates responsive sizes
  • Compresses for web
  • Preserves originals in public/

CSS

  • Minifies stylesheets
  • Removes unused CSS
  • Combines files
  • Adds vendor prefixes

JavaScript

  • Minifies code
  • Tree-shakes unused code
  • Code splits by route

HTML

  • Minifies markup
  • Inlines critical CSS
  • Preloads fonts and assets

Typical Build Times

Site SizeContentBuild Time
Small<50 posts3-5s
Medium50-200 posts8-15s
Large200-500 posts20-40s
Very Large500+ posts60s+

Improving Build Speed

  1. Use incremental builds during development with astrolock write
  2. Optimize images before adding - Pre-resize large images
  3. Reduce media file sizes - Use 128-320 kbps for audio
  4. Limit collection sizes - Archive old content, use pagination

Build Errors

Error: Invalid frontmatter in content/blog/my-post.md
  Line 5: Unexpected token

Fix: Check YAML syntax in frontmatter - quotes, colons, indentation.

Preview Before Deploying

Warning

Always preview your build before deploying to catch issues early.

astrolock build
astrolock preview
# Visit http://localhost:4321

Clean Builds

Sometimes you need a completely clean build:

rm -rf dist/ .json/
astrolock build

Check Build Size

du -sh dist/
# 4.2M    dist/

du -sh dist/* | sort -h

Reduce Build Size

  1. Compress images before adding to public/
  2. Use WebP instead of PNG where possible
  3. Remove unused assets from public/
  4. Archive old content to a separate directory
  5. Limit audio quality to 128-192 kbps for samples

GitHub Actions

- name: Build site
  run: astrolock build

- name: Upload dist
  uses: actions/upload-artifact@v4
  with:
    name: dist
    path: dist/

Docker

docker run -v $(pwd):/site astrolock:latest build

Exit Codes

  • 0: Build succeeded
  • 1: Build failed
if astrolock build; then
    astrolock deploy
else
    echo "Build failed"
    exit 1
fi

See Also

Tip

Run astrolock build --help for all available options.