Skip to content

Instantly share code, notes, and snippets.

@iksi
Forked from bastianallgeier/statify.php
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iksi/2ec4f2aec9e2a1191734 to your computer and use it in GitHub Desktop.
Save iksi/2ec4f2aec9e2a1191734 to your computer and use it in GitHub Desktop.
<?php
/**
* Instructions:
*
* 1. Put this into the document root of your Kirby site
* 2. Make sure to setup the base url for your site correctly
* 3. Run this script with `php statify.php` or open it in your browser
* 4. Upload all files and folders from static to your server
* 5. Test your site
*/
// Setup the base url for your site here
$url = 'http://yourdomain.com';
// Don't touch below here
define('DS', DIRECTORY_SEPARATOR);
// load the cms bootstrapper
include(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');
$kirby = kirby();
$kirby->urls->index = $url;
$site = $kirby->site();
dir::copy(__DIR__ . DS . 'assets', __DIR__ . DS . 'static' . DS . 'assets');
dir::copy(__DIR__ . DS . 'content', __DIR__ . DS . 'static' . DS . 'content');
foreach($site->index() as $page) {
$site->visit($page->uri());
$html = $kirby->render($page);
if($page->isHomePage()) {
$root = __DIR__ . DS . 'static' . DS . 'index.html';
} else {
$root = __DIR__ . DS . 'static' . DS . $page->uri() . DS . 'index.html';
}
f::write($root, $html);
}
?>
Your site has been exported to the <b>static</b> folder.<br />
Copy all sites and folders from there and upload them to your server.<br />
Make sure the main URL is correct: <b><?php echo $url ?></b>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment