{"id":300,"date":"2011-04-30T11:19:02","date_gmt":"2011-04-30T15:19:02","guid":{"rendered":"http:\/\/historicalwebber.mossiso.com\/?page_id=300"},"modified":"2012-12-21T12:32:38","modified_gmt":"2012-12-21T17:32:38","slug":"make-wordpress-static","status":"publish","type":"page","link":"https:\/\/mossiso.com\/code\/make-wordpress-static\/","title":{"rendered":"Make WordPress static"},"content":{"rendered":"<p>Since I had so many WordPress sites to convert into static HTML, I decided to write a nice little bash script for it. This will take care of everything except editing the theme files to take out links to RSS, meta links, or anything else you want removed. It will basically go through the list of steps outlined in this post: <a title=\"Convert WP to static HTML \u2013 part 2\" href=\"http:\/\/mossiso.com\/2009\/07\/20\/convert-wp-to-static-html-part-2.html\">Convert WP to Static HTML Part 2<\/a>.\u00a0 Just upload this script to your server (on the same level as wp-config.php) and run it as a command line program (ie: user@server $ .\/wpstatic). Make sure to change the permissions on the file so that your user can execute it (ex. 744, or chmod u+x wpstatic).<\/p>\n<p>What&#8217;s nice about the script is that it grabs the database info from the wp-config.php and autmagically formats the wget command. So basically, it does the following steps for you:<\/p>\n<ol>\n<li>Update the database to close comments on all posts and pages. Update the database permalink structure.<\/li>\n<li>Checks for a .htaccess file and for the correct rewrite code. If it doesn&#8217;t exist it creates one. If it exists but doesn&#8217;t think the right code is in there, it will append it to the end of the file.<\/li>\n<li>It makes a backup of the database before making the changes, and then again right after.<\/li>\n<li>Reminds you to change the theme files before asking if you would like it to run the wget command.<\/li>\n<\/ol>\n<p>Ideally, you&#8217;ll have edited the theme files before hand, so that you can just run this script, and it will make a static copy of your WordPress blog.<\/p>\n<p>Back by popular demand&#8230; I had to convert a lot of sites again, so I cleaned up the code and added some switches for skipping any of the steps.<\/p>\n<p>Upload the script to your webhost\/server where the WordPress files are located. Then run it on the terminal\/<a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/download.html\" target=\"_blank\">PuTTY<\/a>.<\/p>\n<p>[code lang=&#8221;bash&#8221;].\/wpstatic [option][\/code]<\/p>\n<pre>Usage: wpstatic [options]\r\nVersion 1.2\r\n\r\nRun the script in the directory where you keep the wp-config.php file.\r\nThis will create a directory with a static version of the WordPress site,\r\ncomplete with HTML, CSS, Javascript and images or other media files.\r\n\r\n-a Skip everything (database backups, and htaccess check), just generate the static files\r\n\r\n-b Skip the first backup of database\r\n\r\n-d Skip the second backup of database\r\n\r\n-h Show help text\r\n\r\n-p Skip changing the permalink and closing comments options in the database\r\n\r\n-t Skip check for and changing the .htaccess file<\/pre>\n<h3>Downloads<\/h3>\n<p>Check the git repository for the latest version: <a href=\"https:\/\/github.com\/mossiso\/WP-Static\">https:\/\/github.com\/mossiso\/WP-Static<\/a><\/p>\n<p><a href=\"http:\/\/mossiso.com\/code-repository\/wpstatic-1.2.zip\">Download [wpstatic 1.2, 12\/08\/10]<\/a><\/p>\n<p><a href=\"http:\/\/mossiso.com\/code-repository\/wpstatic_1.zip\">Download [wpstatic 1.0, 8\/13\/09]<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since I had so many WordPress sites to convert into static HTML, I decided to write a nice little bash script for it. This will take care of everything except editing the theme files to take out links to RSS, meta links, or anything else you want removed. It will basically go through the list &hellip; <a href=\"https:\/\/mossiso.com\/code\/make-wordpress-static\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Make WordPress static<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":136,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-300","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P9wosP-4Q","_links":{"self":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/pages\/300"}],"collection":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":9,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/pages\/300\/revisions"}],"predecessor-version":[{"id":1400,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/pages\/300\/revisions\/1400"}],"up":[{"embeddable":true,"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/pages\/136"}],"wp:attachment":[{"href":"https:\/\/mossiso.com\/wp-json\/wp\/v2\/media?parent=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}