Skip to content

elementor/static-html-output

Repository files navigation

Static HTML Output

CircleCI Packagist PHPStan

WordPress plugin to generate a static copy of your site and deploy to GitHub Pages, S3, Netlify, etc. Increase security, pageload speed and hosting options. Connect WordPress into your CI/CD workflow.

Other WordPress SSGs I mantain

WP-CLI commands

  • wp statichtmloutput COMMAND

Where COMMAND can be any of:

  • options
  • generate
  • deploy
  • deploy_cache

Get help for any command by appending --help

Hooks

Modify the initial list of URLs to crawl

  • statichtmloutput_modify_initial_crawl_list
  • Filter hook

signature

apply_filters(
    'statichtmloutput_modify_initial_crawl_list',
    $url_queue
);

example usage

function add_additional_urls( $url_queue ) {
    $additional_urls = [
        'http://mydomain.com/custom_link_1/',
        'http://mydomain.com/custom_link_2/',
    ];

    $url_queue = array_merge(
        $url_queue,
        $additional_urls
    );

    return $url_queue;
}

add_filter( 'statichtmloutput_modify_initial_crawl_list', 'add_additional_urls' );

Post-deployment hook

  • statichtmloutput_post_deploy_trigger
  • Action hook

signature

do_action(
  'statichtmloutput_post_deploy_trigger',
  $archive
);

example usage

function printArchiveInfo( $archive ) {
    error_log( print_r( $archive, true ) );
}

add_filter( 'statichtmloutput_post_deploy_trigger', 'printArchiveInfo' );

example response

Archive Object
(
    [settings] => Array
        (
            [selected_deployment_option] => github
            [baseUrl] => https://leonstafford.github.io/demo-site-wordpress-static-html-output/
            [wp_site_url] => http://example.test/
            [wp_site_path] => /srv/www/example.com/current/web/wp/
            [wp_uploads_path] => /srv/www/example.com/current/web/app/uploads
            [wp_uploads_url] => http://example.test/app/uploads
            [wp_active_theme] => /wp/wp-content/themes/twentyseventeen
            [wp_themes] => /srv/www/example.com/current/web/app/themes
            [wp_uploads] => /srv/www/example.com/current/web/app/uploads
            [wp_plugins] => /srv/www/example.com/current/web/app/plugins
            [wp_content] => /srv/www/example.com/current/web/app
            [wp_inc] => /wp-includes
            [crawl_increment] => 1
        )

    [path] => /srv/www/example.com/current/web/app/uploads/wp-static-html-output-1547668758/
    [name] => wp-static-html-output-1547668758
    [crawl_list] =>
    [export_log] =>
)

Contributing / development

Contributions are very much welcome! Please don't be intimidated to file an issue, create a Pull Request or email me (Leon) me@ljs.dev.

Developing

  • git clone git@github.com:WP2Static/static-html-output.git
  • cd static-html-output
  • composer install
  • composer test
  • composer coverage (optional coverage generation, requires Xdebug)

Building an install .zip file

  • composer build INSTALLER_FILENAME

This will create the installer and place in your $HOME/Downloads directory.

On Windows, you will need the zip utility available to build an installer. I recommend using Git Bash shell and then manually installing the zip utility as per these instructions

Localisation / translations