Generate static HTML files, (along with all dependencies ) from the Wordpress API!
Built in nodejs. It runs a server on localhost:9424
(by default), which can trigger generation of static HTML files from a wordpress site. (Or any API which returns a similar JSON structure of URLs).
Files are generated to a local outputDir
(as specified in the cfg/config.js
).
These files can then be served without having to hassle Wordpress's DB. Speeding up the site, and securing your server!
Rockfish requires yarn.
-
git clone [email protected]:sociomantic-tsunami/rockfish.git
-
yarn
installs dependencies -
Setup a config file.
-
yarn run build
compiles via babel
Create a cfg/config.js
file in the vein of the cfg/sample-config.js
.
- outputDir is the location the generated files will be stored.
For production or local development, you can set rockfish to run on startup, to do this us pm2's upstart capabilities. (On production run as the rockfish
user).
You can retrieve the generation command for this via yarn run pm2 startup
.
Once installed can currently trigger the api via making a request with a site configuration. http://localhost:<port>/rockfish?env=<environment, eg www as from config >&site=<subsite (if using wordpress multisite)ß>
eg: curl 'http://localhost:9424/rockfish?env=cms&site=de'
. This will trigger site generation of the cms.de site as outlined in the config file.
Generated sites are output to the outputDir
as a root. Sites should have a named subfolder to contain the generated output in the format: static.cms.de
with cms
representing a site grouping and de
the domain as in the config.js
.
Inside of this the full folder structure is built, with releases
containing the previous site versions, and current-release
a symlink pointing to the latest version.
-
yarn run watch
runs nodemon and compiles via babel watch -
Ensure you have
export NODE_ENV=development
in your.bashrc
/.zshrc
-
yarn run tdd
run mocha tests in continuous watch mode. -
Start PM2
yarn run pm2 start rockfish.json --env development
. -
Check the logs
yarn run pm2 logs
yarn run tdd
for watch or yarn run test
to run once.
This is not a replacement for your wordpress installation, but it does let you separate it from the WWW.
You can have yoursite.com
serving static files (regenerated as often as you like), while serve the CMS portion of Wordpress from a more secure (password protected? offline?) server.
Static site generation can be triggered every time you update content. So if you only want to show 'latest posts', this is not a problem.
More advanced dynamic sites, customising per user, or needing users to log in etc wont work with this. Sorry. Rockfish is a simple creature for the simple sites out there that want to negate Wordpress' basic bottlenecks of SQL/PHP and keep things more secure.
We gladly accept and review any pull-requests. Feel free! ❤️
This project adheres to the Contributor Covenant. By participating, you are expected to honor this code.