Simply Static Pro now has a pretty extensive integrationThe act of combining different systems, software, or functionalities to work together as a unified whole. with WP-CLI.
We will cover the basics of using Simply Static with this command line tool as we added a lot of interactivity and help right into the CLICommand Line Interface. This is a text-based way to interact with your computer or specific software, like Simply Static… integration.
Table of Contents
Getting started
As you may already know, you can interact with WP CLI by typing “wp + command” into the terminal of your WordPress installation directoryA folder in a computer’s file system used for storing files and other directories.. We won’t cover the basics of WP-CLI, so if you want to learn about it, follow the official documentation here.
All commands of the integration are prefixed with “simply-static”. So just type “wp simply-static” to get an overview:
wp simply-static
Run an export with WP-CLI
To run an exportThe process of saving the files and data from your WordPress site to create a static site. with WP-CLI, we implemented the “run” command:
wp simply-static run
By default, it will start a full static export. However, you can use some optional arguments to run single or build exports.
Single Export:
wp simply-static run --single=123
123 is the post IDA unique attribute used to identify a single element on a webpage. It is often used for linking, styling, or scripting. you want to run a static export for.
Build Exports:
The same pattern is used for build exports. You can use the build id to trigger a specific one:
wp simply-static run --build=123
Include/Exclude files and pages
You can also exclude or include files and pages from the export within the CLI integration. We show you how to include files as both commands work similarly:
wp simply-static includes
Once you hit enter, you will get additional commands to include files and a list of optional arguments.
wp simply-static includes add_file <path> [--blog_id=<blog_id>]
or: wp simply-static includes add_url <url> [--blog_id=<blog_id>]
or: wp simply-static includes list_files [--blog_id=<blog_id>]
or: wp simply-static includes list_urls [--blog_id=<blog_id>]
or: wp simply-static includes remove_file <path> [--blog_id=<blog_id>]
or: wp simply-static includes remove_url <url> [--blog_id=<blog_id>]
You can optionally set the blog_id argument if you run a multisite environment and you only want to handle these settings for a specific subsite.
We use the add_url command now to dig a bit deeper into what is expected. As you may have already thought, you need to provide the URL of the page you want to include. Always make sure to use an absolute URL, not just a path.
wp simply-static includes add_url <url>
The other commands work in a similar way. For completion, here is the overview of the commands when excluding files:
wp simply-static excludes
usage: wp simply-static excludes add_url <url> [--do_not_follow=<do_not_follow>] [--do_not_save=<do_not_save>] [--blog_id=<blog_id>]
or: wp simply-static excludes list_urls [--blog_id=<blog_id>]
or: wp simply-static excludes remove_url <url> [--blog_id=<blog_id>]
or: wp simply-static excludes update_url <url> [--do_not_follow=<do_not_follow>] [--do_not_save=<do_not_save>] [--blog_id=<blog_id>]
Updating Forms
You can add new form integrations from the CLI pretty easily with:
wp simply-static forms
usage: wp simply-static forms add_form [--blog_id=<blog_id>]
or: wp simply-static forms list [--blog_id=<blog_id>]
If you use the add_form command, you must add all required parameters to add a new form connection. As there are quite a lot of fields that need to be filled out, we made it interactive and added a little prompt base approach to the CLI integration:
wp simply-static forms add_form
Title My Form
Choose a Tool:
- cf7 : Contact Form 7
- gravity_forms : Gravity Forms
- external : External Service
Tool: cf7
Form ID (Required if using Form plugin) 12
Subject (Only required when using a form plugin.) My subject
Name (Add a comma-separated list of the name attributes of your form.) myfield-1,myfield-2
Message (Use HTML) This is the body content
E-mail (where the e-mail should be sent to.) support@simplystatic.com
Success: Form Created.
Updating options
You can also update options in Simply Static via CLI now by using the “update” command:
wp simply-static update
usage: wp simply-static update deployment <command>
or: wp simply-static update general <command>
As you can see, right now, we only provide this command for deploymentThe act of pushing the static files generated by Simply Static to a live environment where users can access them. and general options as some of the more advanced options, like forms and search, have some interactivity (like AjaxA technique for updating parts of a web page without refreshing the whole page. It allows for faster and more interactiv… requests) attached to it. We will extend the commands for that in the future.