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

By Daniel Scocco

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.

static page wordpress

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?



Share

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

  • Mike Panic

    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.

  • LGR

    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.

  • Nathan

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

  • TheAnand

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

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

  • Daniel Scocco

    @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.

  • Mary-Ann Horley

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

  • Matt @ Permanent Fitness

    Is it not easier to use a noindex plugin of some sort?
    Examples:

    http://yoast.com/wordpress-noindex-specific-posts-and-pages/

    http://yoast.com/wordpress/meta-robots-wordpress-plugin/

  • Melissa Donovan, Copywriter

    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.

  • Ruchir Chawdhry

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

  • Ralph

    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.

  • Nathan

    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?

  • Young

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

  • Daniel Scocco

    @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.

  • Florin

    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

  • Mike

    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.

  • Jaydip

    Hey Daniel ,

    If we use that facility and edit robot.txt by blocking http://www.yourdomain.com/main-product-page/ then will it going to effect bad on Search engine ?

    Share your view.

  • laptop

    i like this post. some good information.

  • Glenn Nicholas

    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 Chukwudi

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

      Thus I’ve applied it to my new site 😉

  • Bean

    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?

  • Tony Abaca

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

    Visit my site at http://www.churchofchristblog.com

  • traffer

    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.

  • Keith Davis

    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.

Comments are closed.