The Code Snippet
<b:if cond='data:blog.url == "http://example.com/"'> <a href='http://example.com/?m=0'>GO TO HOMEPAGE</a> </b:if>
What It Does
example.com/index.html will see the “GO TO HOMEPAGE” hyperlink and be directed to
example.com/?m=0 where the hyperlink won't be displayed. All hyperlinks will be appended with the
m=0 query parameter.
How It Works
You may have noticed the
m=1 query parameter appended to every link on a mobile template. (I’m guessing the "m" stands for Michigan?) In mobile view you have the option to “View web version.” Doing so changes
0. This effectively gives you three different ways to style any given page of your blog. You could make up your own query parameters but
m= is special because Blogger’s back end does all the work.
When you leave a comment in web view the query parameter doesn’t carry over to the next page. Thus any links to the homepage are links back to your splash page. It’s a vicious cycle! Interestingly, this doesn’t happen when
m=1. It might be a bug but I’m not so sure Blogger sees it that way. I mean, if you leave a comment on a page without query parameters it’s the same as when
UPDATE (1.10.12): Brett Morgan sent the following tip on the Blogger Developer Group.
One of the guys on the team had a good look at your tutorial, and came up with the suggestion of possibly using either HTML5 localStorage or cookies instead of overwriting the mobile param. =)
If you don’t care about SEO then go for it, I guess. I was looking into archiving an old website using Blogger. An old website with a splash page, also frames. (Gasp!) I don’t plan on it being visible to search engines so anything goes I suppose. I just want to see if it’s possible. Maybe you’ll find a better use for this code snippet than splash pages. If you do, share your findings in the comments.
New York photographer, party mammal, and Internet troll for hire. Alain-Christian is an OG who’s been blogging for over 20 years dating back to the early days of AOL. He loves sharing his offbeat opinions on pop culture, bestowing his tech knowledge, and making arts.