The homepage on a site we've developed has four pieces of content: the parent page and three further "pages" of text which we bring into the parent page using PHP. Call them Foo, Bar1, Bar2, Bar3 if you like.

Maybe this is or isn't the correct way to solve the problem of a complex page but it works for us and for the client and he's used to it now.

enter image description here

The small problem is that these pseudo-mini-pages Bar1, Bar2 and Bar3 are indexed by Google and can be served as pages in their own right. They don't look terrible when served that way but we'd like to avoid it if possible.

I figure I can fix this by:

1) redirecting mysite/bar1 to mysite/foo in htaccess
2) via our SEO plugin (Yoast) apply a robot noindex

But I'm asking here which approach is more correct or whether there's a better way?

2 Answers 2


Well those are two different things:

  1. A redirect means they are not accessible any more at all.

  2. noindex just means that search engines ignore it while it is still accessible if you access the URL.

So I'd recommend option 1. This is a simple way of doing this that you can improve an. (E.g. this expects to have a static front page set and doesn't handle any other situation)

function wpse_211889_template_redirect()
    if ( ! is_page() ){

    $frontpage_ID = get_option('page_on_front');

    global $post;
    if( $post->post_parent && $frontpage_ID === $post->post_parent )
        wp_redirect( home_url() );

add_action( 'template_redirect', 'wpse_211889_template_redirect' );

The pages should not be indexed if there are no direct links to them. Search engines don't guess at URLs, so I am guessing that a large part of your problem here is with your own code-- that is, you are generating links somewhere that the engines can follow.

If it were me, I'd create a new post type for this usage and register it with 'public'->false so that the "pages" would only be accessible if you explicitly write code to display them. This should avoid issues with such things are generated search results, RSS feeds, and other potential issues as Core code will help to control what is displayed.

  • I'd say relying on no links to the URLs at all is fragile. One link from an external source, RSS feed, an indexed search or whatever and you'll have it crawled.
    – kraftner
    Dec 15, 2015 at 14:57
  • ... which is why I said to create a new post type with 'public'->false. That should cover search results, feeds, etc. There is nothing you can do about truly external links though, except ask the offending site to remove them.
    – s_ha_dum
    Dec 15, 2015 at 14:59
  • 1
    The post type method is usually what I do when dealing with columns. It's just painless to make them unindexable and I can specifically label them "Homepage Columns" so there's no confusion.
    – Howdy_McGee
    Dec 15, 2015 at 17:58
  • A custom post type is the correct way to do this IMO
    – Andy
    Dec 16, 2015 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.