A Static Home Page

October 26th, 2006 by Mark

I’ve been thinking about making a static home page for Toshuo.com for quite a while. According to my site traffic logs, most of the visitors to this site are new visitors who come in through search engines as opposed to regular readers. I suspect that most people who stumble across this site have come looking for specific information, and probably aren’t interested in the majority of what I blog about. Not only that, but I wouldn’t be surprised if a large number of them weren’t really sure what a blog is.

So as not to bewilder the SE traffic, I decided to make a home page for the site that would have the things I’ve written that are the most useful to the most people possible. Those would be the javascript tools I’ve made, the posts useful to new EFL teachers, and the resources for people who are studying Chinese. After deciding what to do, I’ve spent quite a while trying to bend Word Press to my will and basically come up empty. Wordpress will allow users to make a home.php file that will be loaded as a home page, but it’s completely useless since that new file will be read even when you directly load index.php. There result is that you can have a static home page, but then you can’t have a page that loads up your most recent posts like the home page does by default. There are even plug-ins for static home pages, but they all suffer the same weakness- you lose the “blog” page.

As far as I can tell, after scouring hundreds of forums and looking at the sites I read, the way most people handle this problem is by moving their entire blog into a sub-directory named something like blog, or news, or life. It’s a nice solution in theory, except that I have no intention of breaking all my permalinks and putting a superfluous word like “blog”, or “news”, or “life” into every last one of my URLs from now until I quit blogging.

What I really want, is to make a static home page, move my old home page to a page called http://toshuo.com/blog/ or something like that, and not have my post or category links change at all. Unfortunately, this simple thing seems to be beyond the abilities of WP. I even tried writing my own blog.php file that would do everything that index.php does now. Unfortunately, it didn’t work. Wordpress has some functions in various default files that don’t work when called from elsewhere.

In the end, I beat Wordpress by circumventing it completely. Apache checks for index.html before index.php. So, I just rolled my own home page. My new static home page is loaded at http://toshuo.com/, and my blog page is now http://toshuo.com/index.php. Take that Wordpress!

Tags: , ,

10 Responses to “A Static Home Page”

  1. 1 Darin Says:

    I tried to do something similar once before and also couldn’t get it to work, but supposedly it is possible.

    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    That link is from inside the options panel in the wp-admin.

  2. 2 Mark Says:

    That link is talking about doing something a bit different. It tells you how to move your wordpress files into a sub-directory, without changing the appearance of your blog at all. It won’t do anything to your home page.

  3. 3 trevelyan Says:

    First of all, nice site redesign Mark.

    As far as the technical challenge here goes, one solution might be to change your default “page not found” page into an intelligent redirection script written in PHP. For every page that isn’t found simply grab the requested URL and parse in your new blog subdirectory on the fly. Then redirect to the new page.

    To prevent infinite loops, just have the page pass itself a variable by appending something to the new URL and then query for it using $_GET. If your variable returned positive you would be hitting the script a second time and could print out an error message instead of further redirecting. A bit messy, but might be the easiest solution.

  4. 4 trevelyan Says:

    “To prevent infinite loops, just have the page pass itself a variable by appending something to the new URL and then query for it using $_GET.”

    More easily, just check to see if the address of the requested page already contains your subdirectory.

  5. 5 Mark Says:

    That sounds like a good suggestion, but I’m a bit confused. What would this sort of redirection have to do with making a static home page? I’m not really getting any hits to non-existent URLs to speak of.

  6. 6 Darin Says:

    Doh.. So it does the opposite.. :( Maybe if you do it backwards ;)

  7. 7 Matt Says:

    Silly question: what does it mean to “roll” a homepage? I’ve seen this type of wording pop up in a few places recently and I’m just wondering where it comes from…

  8. 8 Mark Says:

    You know, by hand… like with a rolling pin ;)

  9. 9 Matt Says:

    Aha! I get it now… maybe it’s also like rolling your own spliff… :-)

  10. 10 Mark Says:

    I finally found out how to do beat an index page template out of Wordpress. The page “index” now loads my last 10 entries, just like root used to. Now I can make my home page all PHP-adellic again! Yeah!

Leave a Reply

Quicktags: