StaticWire by christophengelmayer

Convert pages to static HTML files via CLI or the admin interface.

StaticWire

ProcessWire Module that converts pages to static HTML files via CLI or the admin interface. Useful in CI/CD scripts or to use ProcessWire as a static site generator.

Installation


Install via the ProcessWire modules directory. See Instructions.

Configuration


The configuration option ("Static file path") defines the directory in which the static HTML files and folders are generated. The path is relative to the root directory of your ProcessWire installation. (default: /static)

Usage


via CLI (Command Line Interface)

Navigate to the root folder of your website:

cd /var/www/mysite

Run the script

php site/modules/StaticWire/cli.php

via admin interface

Go to Setup > Static Site Generator and click the "Generate" button.

Users need the staticwire-generate permission in order to run StaticWire.

How does it work?


The module creates a folder structure mirroring the page tree of your website. In each folder a index.html file with the corresponding page content is generated.

To generate the static HTML structure the $page->render() function is called on each page.

Asset handling

Assets (like CSS or JavaScript) and uploaded files are not copied!

To handle assets and uploads you have multiple options:

  • copy the folders (site/assets/files, site/templates/style, site/templates/scripts, etc.) to the output directory (static/)
  • copy them in your CI/CD script
  • create symlinks if the static site and your ProcessWire installation are running on the same server

Roadmap


  • [ ] Supprt paginated templates
  • [ ] Download static site as *.zip archive

Alternatives


If you need a more advanced solution please have a look at Ryan Cramers wonderful ProCache module.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #548
    In the 548th issue of ProcessWire Weekly we're going to check out a couple of new third party modules, introduce the latest ProcessWire core updates, and more. Read on!
    Weekly.pw / 9 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits