Hiding Static Pages from Main Page in Blogger

Hiding Static Pages from Main Page in Blogger

Since I wrote the post titled Create Static Pages in Blogger – Part 2 I have been asked on numerous occasions about hiding the static page from the homepage or main page. For blogs without many posts, the static pages may appear on the homepage when someone visits the blog.

It isn’t hard to hide static pages on your blog’s homepage, but it does take a bit of coding, much like it was to create the static page. In this post, I’ll explain what you need to change to prevent the static pages from appearing on the homepage of your Blogger blog.

Hiding the Static Pages

Blogger Logo

As you may know, static pages are regular post pages, but the code within the template causes them to look different when displayed. Since they are regular posts, they could show up on your blog’s homepage.

To prevent them from appearing, you can use the following steps:

  1. First, if you haven’t already done so, create a static page by following the steps outlined in Create Static Pages in Blogger – Part 2.
  2. Once you have created a static page, make a backup of your current template before proceeding.
  3. Next, open your template in the HTML editor within Blogger. We will be editing the HTML, so we will need to work in that editor.
  4. Click the “Expand Widget Templates” checkbox to ensure all the code is displayed.
  5. Using your web browser’s “Find” feature, search for the following:
    <b:loop values='data:posts' var='post'>

    This is where Blogger will loop through the posts that will be displayed on each page. For individual post pages, only one post will be shown, while a homepage will have many.

  6. Now comes the tricky part, replace the following lines of code:
    <b:loop values='data:posts' var='post'>
      <b:if cond='data:post.dateHeader'>
        <p class='date-header'><data:post.dateHeader/></p>
      </b:if>
      <b:include data='post' name='post'/>
      <b:if cond='data:blog.pageType == "item"'>
        <b:include data='post' name='comments'/>
      </b:if>
      <b:if cond='data:post.includeAd'>
        <data:adEnd/>
        <data:adCode/>
        <data:adStart/>
      </b:if>
      <b:if cond='data:post.trackLatency'>
        <data:post.latencyJs/>
      </b:if>
    </b:loop>

    with these lines of code:

    <b:loop values='data:posts' var='post'>
      <b:if cond='data:blog.url == data:blog.homepageUrl'>
        <b:if cond='data:post.dateHeader != "June 23, 2006"'>
          <b:if cond='data:post.dateHeader'>
            <p class='date-header'><data:post.dateHeader/></p>
          </b:if>
          <b:include data='post' name='post'/>
        </b:if>
      <b:else/>
        <b:if cond='data:post.dateHeader != "June 23, 2006"'>
          <b:if cond='data:post.dateHeader'>
            <p class='date-header'>
              <data:post.dateHeader/>
            </p>
          </b:if>
        </b:if>
        <b:include data='post' name='post'/>
        <b:if cond='data:post.dateHeader != "June 23, 2006"'>
          <b:include data='post' name='comments'/>
        </b:if>
      </b:if>
      <b:if cond='data:post.includeAd'>
        <data:adEnd/>
        <data:adCode/>
        <data:adStart/>
      </b:if>
      <b:if cond='data:post.trackLatency'>
        <data:post.latencyJs/>
      </b:if>
    </b:loop>

    Note:

    Remember to replace the date and format shown above with your own or this code won’t work properly.

  7. Click the “Save Template” button at the bottom to update your template. If there are no errors, view your homepage to ensure your static pages are hidden.

How the Code Works

For those interested, here is what the actual code is doing:

Blogger begins to loop through the posts using this line:

<b:loop values='data:posts' var='post'>

Next, we check to see if current page (data:blog.url) is the homepage (data:blog.homepageUrl) with this line:

<b:if cond='data:blog.url == data:blog.homepageUrl'>

If it is, we then check the post date to see if it doesn’t match our static page date. Also, if you created more than one static page, we must include a date check, since other pages after the first page for a date don’t have a date header associated with them.

<b:if cond='data:post.dateHeader'>
<b:if cond='data:post.dateHeader != "June 23, 2006"'>

If the date doesn’t match, then we display the post on the page:

<p class='date-header'>
<data:post.dateHeader/>
</p>
<b:include data='post' name='post'/>

If it is a static page, then we don’t display it at all. The remainder of the code displays the post or static page for all other pages on the blog.

That is all that is needed to hide static pages from the homepage in a Blogger blog.

74 Responses to “Hiding Static Pages from Main Page in Blogger”

  1. Shad says:

    Great web site. Plenty of useful information here.
    I’m sending it to a few friends ans also sharing in delicious.

    And naturally, thank you for your effort!

  2. Doreen says:

    You could certainly see your enthusiasm within the work you write.
    The world hopes for more passionate writers like you who aren’t afraid to say how they believe. All the time go after your heart.

  3. Lee says:

    Hi I am in the process of setting up my first blog. I enjoyed reading your post much of it is way past me at the moment . But what I have done is put it in favourites so I can come back to it when I wm a bit more blog literate.

    So for that thanks lee

  4. Jose Oca says:

    I have seen that there is a feature in blogger to hide a page. Go to “Settings”, “Layout”, then click on static pages section “Edit” link. A new window will pop up.

    Then you just have to uncheck those page you want to hide.

  5. Nice! Thanks a lot for sharing this. It’s a very helpful tips!

  6. ibsen says:

    I set up satic page as you said
    but when i post new posts, they comes in the main page
    and i will have to post the static page again.

    any solution for this?
    so tat even when i post new posts, the static page remains on the main page.

  7. nedo says:

    please help me i want to hide my only single one page from being displayed in side bar that should be always hide not shown even in homepage

  8. Aniket says:

    I guess the tutorial needs to be updated. I am not able to find the exact code to be replaced even after Expanding Widget Templates. I need it urgently. Plz help.

    • Paul Salmon says:

      It all depends on how your Blogger template is setup. The code may not match exactly, but the same tags should exist in your template. In that case you would need to make the adjustments to match your template.

  9. justin says:

    Hi..i’m actually having what I think to be the opposite issue…my static pages show up on my home page and i want them to, but when you visit them, you only get the title link and not the whole page…is there something else i need to do? any help will be greatly appreciated.

  10. jesseina says:

    dear paul,

    ive done this trick several times with different templates. it worked like magic! THANKS TO YOUR MAGIC TOUCH!

    but this is the first time it has gone wrong.

    it is perfect immediately after i save and view the blog…but when i refreshed , the ‘phantom’ page that im suppose to hide starts to appear . i think, there’s something wrong with the looping because there were two of in the template. please help!

  11. Tina says:

    I used the browser finder to find the loop code and it shows that I had the same exact code three different times and the lines that follow don’t look like the codes that needs to be replaced… what should I do?

  12. Sarah says:

    Please disregard my previous message. I’ve searched google and found what I need to clear up my latest issue.

    Thanks again!

  13. Sarah says:

    Thank you!! Thank you!! The suggestion to download an XML Editor was the best yet. I now have one final error that the Editor does not seem to find …and I still cannot save the template. See error in next paragraph:

    The processing instruction target matching “[xX][mM][lL]” is not allowed.

    I’m unable to locate anything like this in my template. Any suggestions as to where I might look or how to resolve?

    Again, thanks for the tip on the editor.

  14. Sarah says:

    Thank you for your excellent instructions and explanation! I made all the changes and worked through the error messages – however, I am unable to find the issue with the message below. Body has been closed with html . Please assist.

    Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
    XML error message: The element type “body” must be terminated by the matching end-tag “”.

    • Paul says:

      This issue usually occurs when you have an open tag but haven’t closed it properly. Check all your tags to ensure they are all closed. Also, you may also want to ensure that your quotes are proper and then they aren’t odd looking.

      The best way of looking for the problem tags is to find an XML editor online and install it on your local machine. The editor within Blogger is not easy to use when it comes to finding errors in your template.

  15. Michelle says:

    I left a comment before, but it didn’t get responded to.

    Thank you so much for helping us that are less than technologically savvy. I’ve been trying to hide my static page using your method to no avail. The majority of text that you state that I should replace is not anywhere in my template all in one place. Just bits and pieces of the text scattered in different sections. I’m able to hide the static pages a little because they’re not on the main page, but I’m trying to hide them completely. Meaning, if someone clicks on “older posts”, they won’t see the static pages. Can you help me?

    • Paul says:

      I haven’t played around with preventing the static pages from appear if some clicks the older posts link. I may be able to do it from a post page, but from an index page, it may not be doable.

      I’ll play around with it and see what I can do.

    • T. Larking says:

      Michelle – while I was searching around for info on static pages myself, I came across a post that says you can set the date forward in time (say, 10 years) in order to trick the blog and keep it from archiving.

      Don’t know if that’s what you needed, but hope maybe it helps? Otherwise I’d just keep trying the google search. Good luck…

      • Michelle says:

        T. Larking – thanks for trying to help. Unfortunately, that’s not what I’m looking for. What I’m looking for is that my static pages not being seen anywhere on the blog except for the specific link that leads to it. Basically, my static page is a FAQ page. Although, I have it set so it doesn’t show on the archive list, if you click on “older posts” you’ll eventually see it. If I use your suggestion, the post remains on the main page because the date is set in the future, although I can hide the datestamp.

  16. Sarah says:

    Sorry – element type “body” has been followed by

  17. Sarah says:

    Thank you for your excellent instructions and explanation! I made all the changes and worked through the error messages – however, I am unable to find the issue with the message below. Body has been followed by . Please assist.

    Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
    XML error message: The element type “body” must be terminated by the matching end-tag “”.

  18. T. Larking says:

    Hi there – I am a new blogger trying to cobble together my blog, and hoping someone can help! I used the backdating method (and forward dating for the home page) to make static pages linked to a navigation link bar under my header.

    However, I am baffled as to how to make the “journal” link I made connect to regular blog posts I upload. I made a normal blog post and noticed it exists in the edit posts list, but I don’t know how to get it to load on the ‘journal’ page.

    I am probably just doing something really stupid….but can’t see it.

    Please have a quick look and help if you can?

    • Paul says:

      I don’t think that is possible within Blogger’s code, probably Javascript can do it, though, but I haven’t looked at that option. The reason for that is how Blogger displays posts. When you display your homepage, Blogger allows you to loop through several posts to display on that page within the blog gadget. The number of posts depends on the settings in your blog.

      When a post is displayed, only that post can be displayed by the blog gadget, which is why you can show multiple posts within a single post.

      • T. Larking says:

        Hmm, so just to clarify – if you make your ‘home page’ into a static page, there really is no way to have any of the links then connect to a page that functions as a ‘normal’ blog….?

        I saw somewhere, where someone was actually able to make a “posts” link in their navbar – but haven’t been able to find out how. Though I will try and find a workaround by tweaking the settings.

        Also, I didn’t realize were were able to add javascript to blog template code… I’ll look into that too.

        Thanks very much in any case. 🙂

        • Paul says:

          After I left my last comment I thought about it for a moment. Technically there is a way to display your recent posts on a post page. It involves something like the following:

          1. Create a post to display the a list of your recent posts, as you have already done with your “Journal” post. Don’t include any content, only the title.

          2. Next add a “Feed” gadget to your template, right below the blog post gadget. For the feed URL, use your blog’s RSS feed.

          3. Next edit your template’s HTML, and surround the code in the Feed gadget with something like the following:
          <b:if cond='data:blog.url != "http://www.faeriesunrise.com/2009/12/journal.html"'>

          This will cause the code in the feed gadget to only display on your journal page. If you have some difficulties, just let me know, and I’ll create a post on how to do this.

          • T. Larking says:

            I’ve been working on the blog all day today – and after pondering about 4 workarounds, I actually did this:

            Created a separate blog (with related title), changed the main-wrapper area so that it’s blank and can function as a template for a, gallery page, etc – without showing any sidebars (wouldnt want those pages to look like a blog).

            Then, dumped the ‘home’ link in favor of making the “home” page BE the blog, and tie links together.

            If I knew more about blogging I might be able to anticipate problems with this setup but for what I need for now it suffices.

            The idea you posted is a good one – if I hadn’t already put so much work into it today I might have tried that!

            In any case – I’m glad I came across your site, you’re very helpful to everyone and its very appreciated. I know my site has nothing to do with computers but I may post a link in one of my posts to your site as a thanks, if it’s ok.

            Cheers for now, tytyty!

  19. anshul says:

    hello paul.. i have following issues with my blog:
    1) i used this hack on my blog but when I click on “Older Post” then my static pages are also shown as posts.

    2)Also when I click on “Older Posts” then the posts starts appearing with comment box below each post.

    3) I am not able to add page navigation in my blog.

    Please have a look at my blog to see the problem, You are my only hope, please help me with these issues..

    • Paul says:

      Can you send me your template, using the contact form in the top navbar, and I’ll fix it up for you.

      • anshul says:

        hi paul,
        i have sent u my template.. thanks 🙂

        • anshul says:

          hello paul,
          thanks a lot for changing my template to my requirement. 🙂 you are gem of a person always ready to help others out. Heartfelt thanks for that.
          i had an issue. i wanted to display post titles only on archive and labels page, but from 2nd page onwards it displays only titles and not textx. i want “titles+text” in all pages and “only titles” in labels and archive pages. can you show me a way around please ?? sorry for troubling you again and again.

          • Paul says:

            That may not be possible because of how Blogger labels the pages. For the labels, archive, and home pages, the page type is “index”. This means that when you specify pageType == “index” in your code, it applies to all three types of pages.

            I’m not sure if there is an easy way of distinguishing one from another, but I’ll see what I can find. In the meantime, you may want to display the title in content on the pages to avoid any issues.

  20. Sarah says:

    Please check my blog …..I would like to be able to click on one of the menu tabs (Memories, Recipes, etc.) and post directly to that page.

    What coding do I need? And, where do I put it?

    Thanks much for your help!!

  21. Michelle says:

    Thank you so much for helping us that are less than technologically savvy. I’ve been trying to hide my static page using your method to no avail. The majority of text that you state that I should replace is not anywhere in my template all in one place. Just bits and pieces of the text scattered in different sections. Can you help me?

  22. Jennifer says:

    Thank you so much for taking the time to post these extremely helpful tips! I think you do an excellent job of explaining the process and make it easy to understand. I am having an issue with this code however. When I put the code in my blog still publishes the pages and also adds back in the post date which I removed in an earlier step. Any idea what I am doing wrong? Thanks again for your help!

    • Jennifer says:

      Okay I figured out my initial problem (I forgot to put in the day of the week!) but now I have another problem. All of my new posts show the date twice in the posting. This did not happen before I added this code. Any suggestions?

      • Paul says:

        It depends on your code. You may have post.dateheader called twice which will dispay the date twice, or you may have forgotten to close an if statement.

  23. ill66 says:

    i just could try it out in a hurry (i’m @work right now 😉 ), but the only thing happend was, that on the main page only 3 postings apperad (instead of 8) – on the second page (“older posts”) everything’s displayed normal, but also the static page is listed there…

    • ill66 says:

      back @home, i just tried again (several things – your modified code, changing the code line by line), but in both cases happens as follwos:
      on the first/homepage all postings disapear, which have no own date-line (i.e. all those, that have been publishes on a same day), on the second page all posts are still existent (also those with no date-line), inkl. the static page.
      if that may help…

      • Paul says:

        Did you include the following on your homepage in your template:<b:include data='post' name='post'/>? This is what displays the posts.

        • ill66 says:

          yes, i did, since i just pasted your abovementioned code…

          • Paul says:

            Can you send me your full template code and I’ll have a look?

            • ill66 says:

              when i use the XML-file you sent me (thx a lot), not only the static pages won’t disapear, but also many of the posts are displayed doubly.
              LOL mysterious….

              • Paul says:

                Interesting. When I tested the template I didn’t see double-posting. The post information is displayed at the<b:include data='post' name='post'/> line. If this is repeated twice for any post then a post will be displayed twice.

  24. ill66 says:

    i just detected my initial code is a little different from yours:
    http://pastebin.com/f524700f5

    is there a solution for me, anyhow?

  25. ill66 says:

    that’s the first one of your hacks i can’t get working 🙁
    i tried several times, but strangely enough the main change was, that the displayed date on my blog seems to loose it’s style information (switched to default).
    several other phenomenons occurred, which i can’t report *dizzy*

    • Paul says:

      When you copy the code, ensure you use the same style (h2 or p) and CSS class that was in your original code. The styling of my code may not match yours.

  26. anshul says:

    thanks a lot for sharing it with us… you are gem of a person..i am impressed and have subscribed to your site 🙂

  27. Evangeline says:

    Hi Paul,

    Is there any way to tweak this code for those of us with customized templates that use timestamp code instead of dateHeader? I’m missing lines 2,3,4 (since I have no date headers) and 14, 15, 16 (not sure why) of the snippet we’re supposed to look for in our templates.

    • Paul says:

      You can still use the dateHeader tag in your code, even though you don’t display the date. The dateHeader is always available, but some templates may not use it to display the date.

      • Evangeline says:

        Worked like a gem! Thanks so much!

        • Evangeline says:

          Actually, there is one hiccup – adding the new code has resulted in date headers being applied to my non-hidden posts. Any easy fix for this?

          • Paul says:

            Can you clarify “non-hidden posts”?

            • Evangeline says:

              Non-hidden posts = The posts on my blog I don’t want to make hidden static pages; regular blog posts. I went into my blog post menu and unchecked the date header option in an attempt to get rid of it, but this ended up hiding every single post on the blog.

              • Paul says:

                Did you want to remove the date header from all your posts? You can try editing the HTML for your posts and remove the tag from your template. Be sure to backup your template first.

                • Evangeline says:

                  I couldn’t find any date header tags except for this code, but changed the dates to white so they won’t show up instead. 🙂
                  In the meantime, however, I’ve discovered I have the same problem as Roj above – only the first post of the day shows up, nothing afterwards. I’ve doublechecked my code for the same date error, i.e. putting the wrong date or the wrong format, but it’s all correct. Any advice?

                  • Evangeline says:

                    Clarification: the posts made on my phantom date have disappeared like promised; the problem I’m having is the additional disappearance of all posts after the first post on a non-phantom date.

                    • Evangeline says:

                      Any suggestions for solving this problem? I don’t have much expertise in HTML, so I’m at a loss. :/ I would really like to post multiple times in a day – and have all the posts show up.

  28. Alannah says:

    Hi Paul,

    Thank you for posting the codes! I tried this on my test blog, and it does hide the static page, but unfortunately, it also hides other posts that have a different, more current date. I posted it as was shown above, and the backdated post for the static page is dated August 14, 2007, and the “newer” post is dated September September 14, 2009. I thought it might be the fact that they both have a date of 14 that was causing the problem, but when I changed the newer one to September 13, 2009, it still had this same problem. What do you think could be causing this problem? Thank you so much!

  29. jared says:

    Thanks Paul, Unfortunately I have the Allow Comments option chosen for all three static pages. At the bottom of the pages there is the normal “Posted By” and “time”, but no link to leave comments, which is why I thought it may be something in the code where it loops through the date and time stamps. It’s odd indeed.

  30. jared says:

    Paul,

    Thanks again for your help, I was wondering if I could trouble you one last time. Is there a certain place in the code to look to ensure that the comments box will appear in the static pages? Viewers are able to leave comments on my main page under the posts, but on each static page there is no link to comment only the “Post Comments (ATOM)” link. I am wondering if I altered the code somehow when following the instructions you posted for creating static pages version 1 and 2.

    Thanks!

    Jared

    • Paul says:

      Depending on which static page tutorial you followed, you may have disabled the comments for your static page. In version 1 I mention disabling comments when creating the static page. In version 2, you can keep the comments enabled.

      At the bottom of the post editor, click the “Post Options” link. Under “Reader Comments”, ensure the “Allow” option is selected for you static pages.

  31. Roj Blake says:

    Man, I super appreciate the work you’ve done sharing your solutions. I just did the way to hide it from the archive, and that worked perfectly, but I can’t get this to go. Maybe I’m not so good at this:

    I’ve pasted the code in, and instead of hiding the posts matching the “Phantom Date”, it’s hiding any post made on the same day, after the first made on that day. (ie only the first post of the day will show up).

    I did notice, and it’s really bugging me, that the quotes around “June 23…” in the code have been replaced by " but for the life of me couldn’t get regular quotes to stick. Maybe that’s my problem?

    • Paul says:

      Did you remember to change the date in the code to match your “Phantom date”?

      The quotes in the code will automatically be converted to &quot; by Blogger. This will have no effect on the code. I included the actual quote character above (“) since it is easier to read than including &quot;.

      • Roj Blake says:

        Being the sort of lazy person that uses code generous people post to their blog, and (though very rarely) posts comments complaining they can’t get it to work, I was using the same date as you.

        However, my date FORMAT was including the day as well (ie Sumday, Avril 2020), changing that and it all works.

        I can’t thank you enough for providing this information AND volunteering to help out. A huge help for the less gifted.

  32. jared says:

    I have multiple static pages with the same date, but with the code as I have entered it, it only hides one of the static posts and displays the others. Do I need to change the code in another way?

    Thanks!

    • Paul says:

      I updated the code to move the date check. The problem is that posts after the first one for a specific date don’t have a date header, only a time stamp. I modified the code to first check to make sure the post has a date stamp, before performing the date value check.

      • jared says:

        Paul,

        Terrific! That worked great. Thanks for your help and I really appreciate all the work you have put into this. It has been tremendously helpful and very informative.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.