How To: Using WordPress as a Static Site

This guest post was submitted by Joseph. If you have WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us.

This is the story of one man’s laziness and his quest to build a simple website that any client of his could edit. And leave him alone after the design was done.

I started doing this because I was tired of editing pages in Dreamweaver and uploading it each time a client wanted one word changed in the third sentence of the fourth paragraph on the About Us page. WordPress has a very convenient page functionality, and I decided to make the best of it. Here’s how you do it…

First off, you have to work on the design. You could always start with one of the many WP themes out there. Once you decide on one, though, you need to lose all the peripheral pages. Delete all the php files except for the header, footer, page, and the sidebar (if there is one). Keep the search file as well, for the time being. Then, rename page.php to index.php. Now you’ve gotten rid of the extra files, but many page templates have unnnecessary blogging-related stuff: trackbacks, comments and the meta bits. Delete them all. They usually come wrapped in little divs called “postmeta” or “postmetadata”, or something on those lines. Essentially, look for the divs that contain the tags the_time, the_author, the_tags, the_category, comments_popup_link and so on. You can find more of these template tags here. All you actually need from this page is probably the_post and the_title. Yes, really.

Now, lets get to the header and footer files. In the <head> section, delete the lines which contain links to the RSS feed (rss2_url) and the pingback URL (pingback_url). Similarly, in the footer file, delete any links to RSS feeds. That’s all there is to it.

When you get to the sidebar, you need to make some decisions, based on your requirements and on your theme. First off, is the sidebar widgetized? If it isn’t, get that widgetizing done. Did you delete functions.php a while back? Sorry. Restore it from your recycle bin… you’ll need that. Once your sidebar is widgetized, browse over to the widgets section and add widgets you want. Don’t throw everything in… you don’t need Akismet stats, for heaven’s sake.

Now we get to the search function. WordPress doesn’t search pages. Don’t ask me why. They just don’t. You’ll need a plugin like Search Pages. But first, figure out if you need a search page or not. If it’s a five page site, it’s highly unlikely anyone would need to use the search function. If your site runs into several dozen pages, keep the search function, unless your navigation is idiot-proof. Depending on whether you’re using search or not, keep or delete search.php. If you’re keeping it, don’t forget to remove the meta-stuff from the search results page.

You’ll need a contact form. What’s a static site without a good old contact form? Use one of the many plugins at the WordPress plugin directory.

Your theme is now ready, and you need to strip your CSS file a bit. No point in cluttering up your CSS with classes and ids you’ll never use.

Finally, if you’re doing it for clients who want to edit pages themselves, you don’t want them fooling around with the site settings and themes and plugins. There’s no telling what havoc they could wreak. Not to mention, create more work for you. This is where a very handy plugin comes in: Ryan’s Simple CMS. Set your client as a new user with Editor permissions, and they get a nice clean pages-only backend. They won’t keep writing new posts and wondering why the new page isn’t up. While you’re at Ryan’s you could try his Simple CMS theme as well, to help with your theme. It’s even got a nice Suckerfish menu built in.

Don’t forget the most important thing of all: setting a page as the front page for the site.