50 years ago Sputnik was launched, and ever since children all over the world have dreamed of becoming an astronaut.
http://www.pbs.org/newshour/bb/science/july-dec07/sputnik_10-03.html
General things that deal with technology.
50 years ago Sputnik was launched, and ever since children all over the world have dreamed of becoming an astronaut.
http://www.pbs.org/newshour/bb/science/july-dec07/sputnik_10-03.html
UPDATE: Check out the new post on a better way to do this here: Convert WP to Static HTML Part 2. Or see the page devoted to the script here: Make WordPress Static.
Usually people are wanting to convert their static html pages to some dynamic content management system. I’ve run into the issue of needing to go the other way.
A few professors at GMU love to use WordPress for their classes. It’s a really great way to get more student participation and involve some of those who aren’t so talkative in class.
But these blogs are usually only needed for one semester, and then just sit there. This can be a security risk if they are not kept up to date, and is cumbersome when trying to update many of them (one professor had over 30 blogs!).
Sometimes the content should still be viewable, but the need for a whole cms type back-end no longer exists. Sometimes the professor would just like a copy of the pages for their own future research or whatever.
So, I figured out a way to convert a dynamic WordPress site into static html pages.
Here are the basic steps I used:
UPDATE (2.12.08): Reading a post from Christopher Price (who linked to this post) about WP permalinks, I’m thinking using this structure (/archives/%post_id%.html) might afford the best results. I often found a page that displayed the raw HTML instead of being rendered. This just might fix that issue.
UPDATE (3.11.08): I did some more dynamic to static conversions today, and found out the best permalink structure to use is just the post name. No extra categories and such. So the best structure to use would be this (/%postname%.html). The benefit is that the every page is unique with a descriptive name for the url (albeit sometime very long), and there are not as many subdirectory issues that arise.
UPDATE (7.17.09): This time around, I have found that the following seems to work best for permalink: /%year%/%monthnum%/%day%/%postname%/
And cleaned up the SQL statement.
RewriteEngine On
RewriteBase /path/to/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /path/to/wp/index.php [L]
wget --mirror -P wpsite-static --cut-dirs=3 -nH -p -k -E https://site.com/path/to/wp/
This has the bonus of making the directory for you, thus negating the make directory step. Make sure to use two dashes and not an em dash.
UPDATE (03.11.08): I have found that the old ‘rename‘ command [rename .1 ” *.1]only works on the current directory. If you want to do a recursive renaming you have to use the ‘find‘ command. The above code has changed to reflect this.
UPDATE (7.14.09): When the rename with find doesn’t work, it’s probably because the post has comments, so there is a folder with the same name as the post’s filename. In this case, just move the file (with the .1 extension) into the folder of the same name, but change the name of the file to index.html
What’s with these multiple posts in a day…
Today marks the completion of my Multiple WordPress Updater Script. I’ve already posted a bunch about school stuff, might as well post about work stuff too.
We host over 55 blogs at CHNM. It’s up to me to update them when security patches or new versions come out. Doing them each by hand is a pain. I did a bit of searching but didn’t find anything that would help me update so many sites automatically. So I wrote a bash script that will do it for me. It reads a file that lists all of the wordpress install paths or prompts you for the path to one, prompts for the version to switch to, and a mysql user/pass that has permissions for all databases.
Then the script creates a copy of the database, makes a copy of the wp-content folder, updates the wordpress install using subversion, fixes some permissions, and saves the subversion output to a file in your home directory (which I’ll probably change to somewhere’s else).
I run this via sudo as root for easy updating. What I’m really pleased with is that I figured out how to get the script to pull the database name from the wp-config.php file, and grab the owner and group for later fixing of the permissions.
I hope it can be useful to someone. If you have any comments or suggestions, let me know.
Latest Version: 1.2.3 – 04/29/08
Download file
UPDATE 24.4.08: WordPress Updater has been updated. I also updated this post, took out the code in the post, and put up a link to the file for you to download instead.
I’m facinated with why things are designed the way they are. I recently found a blog about the history of the electromechanical button. In class tonight I was introduced to a series of books about the design of everyday things. I’ll have to check them out at a latter date.