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

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?

Got the Internet Marketing Newsletter?

  • My analysis of the industry
  • The latest trends and opportunities
  • Tips and tricks that I use on my sites
  • It's free!

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

  1. Mike Panic on November 19th, 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.

  2. LGR on November 19th, 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.

  3. Nathan on November 19th, 2008 3:55 pm

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

  4. TheAnand on November 19th, 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….

  5. Daniel Scocco on November 19th, 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.

  6. Mary-Ann Horley on November 19th, 2008 5:24 pm

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

  7. Matt @ Permanent Fitness on November 19th, 2008 7:23 pm

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

    http://yoast.com/wordpress-noi.....and-pages/

    http://yoast.com/wordpress/met.....ss-plugin/

  8. Melissa Donovan, Copywriter on November 19th, 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.

  9. Ruchir Chawdhry on November 19th, 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…

  10. Ralph on November 20th, 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.

  11. Nathan on November 20th, 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?

  12. Young on November 20th, 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.

  13. Daniel Scocco on November 20th, 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.

  14. Florin on November 20th, 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

  15. Mike on November 20th, 2008 7:15 pm

    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.

  16. Jaydip on November 21st, 2008 3:12 am

    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.

  17. laptop on November 24th, 2008 3:43 am

    i like this post. some good information.

  18. Glenn Nicholas on November 27th, 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.

  19. Bean on December 6th, 2008 2:04 pm

    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?

  20. Tony Abaca on December 18th, 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.

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

Got something to say?





Sponsors

Online Invoicing For Freelancers monetize all traffic Put your writing skills to work 6 figure blogging secrets Grammar Check Services Premium WordPress Themes Content rich web directory Why I recommend Doreo Hosting

Popular Articles

Recent Articles