If You Are Going To Use a Static Homepage, Hand Code It in WordPress

By Daniel Scocco - 1 minute read

As most of you probably already know, WordPress is expanding far beyond a blogging platform, towards a complete Content Management System (CMS). In simple words, this means that the WordPress open source software can be used to build virtually any type of website, including blogs, company sites and online stores.

One of the features that WordPress introduced to walk in that direction was the ability to be able to use a static front page. You just need to click on “Settings” and then “Reading,” and select which of your pages should be displayed as the static homepage.

It is a nice feature, but on all my sites where I use a static homepage and WordPress as the CMS I preferred to not use it, and rather to hand code the homepage content directly on the index.php file. Why? Because if you choose to use a specific page as the static front one, you will have a duplicate version of your homepage on another URL.

For example, suppose you put WordPress on your new website that will function as your product store. You then create a page called “Main product page.” WordPress will create the page, and give it a URL like www.yourdomain.com/main-product-page/. If you then select that page to be used as the static front page, that same content will be accessible on the homepage and on the single page URL.

The homepage is the main place that search engine bots will crawl on your website, and if they find an exact copy of that on a secondary URL I suspect it could cause some problems due to duplicate content. It shouldn’t be a big problem, but when it comes to search engine optimization, every small bit helps.

An alternative would be to no-index the single page URL, but I still prefer to hand code the front page on the index.php file.

Did anyway else play with static pages and their optimization before?

Recommended Articles for You

23 Responses to “If You Are Going To Use a Static Homepage, Hand Code It in WordPress”

Keith Davison August 12, 2009 6:51 pm

Never thought of duplicate content… oh dear.
Interesting post and some great comments and information from your readers.
What a clever lot they are.

I shall have to read through all the comments again.

trafferon June 12, 2009 2:21 am

Within the active theme you are using, find in either the header.php or function.php file the line with the Home tag. Delete that entire line and the duplicate should disappear but not affect your menu bar. Save the original file before you make the change in case there is a problem.

Tony Abacaon December 18, 2008 3:06 pm

I would suggest using page.php. Apparently, that’s the default value mentioned in http://codex.wordpress.org to use for primary home pages.

My problem with static home page is that Home shows up twice in themes that use a horizontal menu bar for the pages. Any one have any ideas on how to work around that?

Glenn Nicholason November 27, 2008 12:46 pm

Hi Daniel,
This case is handled automatically by WordPress and you won’t get a duplicate. So there isn’t a need to hand code a Front page.
When you set a static page /Front page, you will find the Permalink option automatically disappears for that page in the Page Editor, and WordPress only returns it as the root page and the permalink version is not.
So lets say you create page XYZ with permalink /xyz, then change your Reading settings to make it your home page, if you go back to the page the permalink field has disappeared. From then on, you can only get to the page at /. If you change the page, you’ll find the ‘missing permalink’ behavior follows the page that is currently your Front page.

Can’t find it documented, but I think this is courtesy of the canonical URL handling that came in with 2.3.

Udegbunam Chukwudion July 30, 2010 11:17 am

Tested it on localhost and it’s excatly as you say. The post automatically redirects to the home page. Thanks for the heads up 😉

If I were only trying to prevent duplicate pages and not something really special that I could not do within WordPress itself I would never hard code anything. I would use redirects among other things to hide the page like was already said above.

Florinon November 20, 2008 12:33 pm

codding is bad for you and for your client, a 301 direct or is robots.tx it’s much better. mainly it’s to complex to edit for the client

Daniel Scoccoon November 20, 2008 6:06 am

@Nathan, the same code you would put on the home.php you put on the index.php, I believe the final result will be the same.

Youngon November 20, 2008 2:58 am

Hmmm, I can’t understand what you are saying, and I just want to ask the same question as NATHAN`S.

Nathanon November 20, 2008 1:44 am

If you use home.php it forces wordpress to use that file as your homepage which is most likely going to be static.

I will also break the reading settings you described above.

How do you hand code a static homepage in the index.php file? Isn’t that what pulls drives the main blog page?

Ralphon November 20, 2008 12:14 am

I like using home.php for my personal pages, but I don’t mind editing the code. Like Mike, I’m doing freelance work using WordPress for a variety of sites, and I find that most clients want to be able to edit their page from within WordPress. So directly editing the home.php code isn’t a good solution for those situations.

In addition to nofollow, I’d also make sure to exclude it from the Google sitemap plugin, if you’re using that.

Ruchir Chawdhryon November 19, 2008 11:58 pm

I don’t really use static pages, and if I want to use them then I just pick a magazine theme that I like…

Melissa Donovan, Copywriteron November 19, 2008 9:46 pm

This is important to keep in mind when choosing a theme as well, since many of them come with a custom home page, which will eliminate the risk of duplicate content.

Yeah, I use home.php, never realised it wasn’t the usual thing? I think the Codex says to use it.

Daniel Scoccoon November 19, 2008 4:47 pm

@Nathan, that is not the standard on most WP themes, but I know Brian Gardner uses that on his themes.

@LGR, yeah a 301 direct is another good solution.

@Mike, that is fine, just make sure you apply either no-index or a 301 redirect.

TheAnandon November 19, 2008 4:34 pm

I used wordpress on my home….I use the is_home()

Actually the blog and the home are two different wordpress installations….

Nathanon November 19, 2008 3:55 pm

I’m pretty sure a static home page should be coded on home.php.

LGRon November 19, 2008 3:24 pm

Two ways to deal with it and keep the static home page as a part of WordPress so you can easily edit it. You can either edit your htaccess file to redirect the url you want or use the redirection WordPress plugin to redirect the duplicate page to the correct URL.

Just a quick thought anyways. Works on my site.

Mike Panicon November 19, 2008 3:20 pm

Like you I use WP as a CMS for many sites, it’s actually enabled me to go back to freelance web work, as I got away from it because I hated hand coding so much.

I’ve never even thought to hand-code the index, or home page before though. Too often my clients either want the ability to edit their homepage themself or they need it changed on a regular basis. If I need to make changes at least once a month, I’m keeping it in WP.