Skip to main content

Blogger Landing Page without losing Blog using Cookies

I followed the tutorials to set a custom redirect in blogger using a static page and discovered that you can no longer navigate back to the ordinary blog.  In fact, all the existing search engine references to your blog posts get lost.  This isn't a great solution.

To address this, I've put together the javascript code below which uses a cookie to recognise a new user.  A Blogger blog already uses a cookie to create the cookie notice that comes up.  One more cookie shouldn't be a problem.

The following javascript works like this: If a new user comes to your page, they are first sent to the landing (front) page.  However, if a new user is trying to get to a specific page, such as a blog post, then the javascript does not redirect them, it just lets them through to where they want to go.  This is achieved by checking if a cookie exists.   If the cookie does not exist, we assume they have not visited the page before, and the cookie is created for the next time they visit.

Importantly, if you simply redirect from the main address of your blog to your landing page, they will never be able to navigate to the blog itself.  So this cookie creates a once-only solution unique to each visitor.

You can use the following piece of code to redirect new users of your Blogger blog to a customised static page.  You need to copy and paste this code into the <head> section of your blogger template.  You can do this by navigating through the Blogger control panel, Template, Customize HTML (guide here).  When you are looking at the HTML, search for </head>, and paste the below code just before </head>.

Be sure to back up your custom html / template first, just in case something goes wrong.

Important: you need to change a few lines in the below code.

  • var homepage_url = "";
    • Change the web address here to the web address of your blog.  This might be "", or something similar.
  • window.location = "";
    • You need to change the web address here to the address where you want your user to end up.  To create a landing page, use the Blogger control panel to set up a static page (tutorial here), and then use the URL you find in the address bar when you are on that static page.

<script type='text/javascript'>;

// Blogger Landing Page Redirect by
// Paul O'Dowd
// 23 May 2016

// Get current cookies for this page.
var existing_cookies = document.cookie;

// Get URL string from address bar
var incoming_url = window.location.href;

// Add your homepage url here:
var homepage_url = "";

  // Check to see if the user is addressing the webpage directly.
  // If they want to go to a specific blog post we let them through.
  if( incoming_url.toLowerCase() == homepage_url.toLowerCase() ) {
  // If the Second Visit cookie does not exist, we send the user
  // to the landing page.
  if("Second Visit") == -1 ) {

    // Create the cookie so if the user visits again
    // they don't go to the landing page.
    document.cookie = "Second Visit";

    // Send user to landing page.


You can test if this is working quite easily by opening up a Private Window in Firefox, or Incognito Window in Chrome, and navigating to your page.  Cookies are automatically deleted when you close a private/incognito window.

The following pages might be useful resources if you want to develop the above code further:

Popular posts from this blog

DIY Planar Magnetic drivers, part 1

I've been putting together some planar magnetic loud speaker drivers.  There is a wealth of information available at, particularly in this thread.   Inner Fidelity have a nice write up on planar magnetic drivers.  Euwemax documents his DIY planar magnetic drivers for headphones, and he uses etching as his principle method.  I thought I'd attempt to build some using enamelled wire and embroidery hoops.  This post documents my progress so far.  I've made working prototypes, but at the moment the sound is clipping.

Arduino, Smooth RC Servo Motor Control

When using the arduino Servo.h library, you normally use myServo.write(), but you can use myServo.writeMicroseconds().  This lets you write out the controlling squarewave period in microseconds.  The rc servo standard is typically 1000us <-> 2000us, with 1500us as neutral position.  This means that you have a resolution of ~2000 individual steps, rather than the 180 (degree) steps the normal write() would provide - and therefore, the potential for significantly smoother servo motor movements. 

Check out:

Here is the test code I have used to good effect so far, I have been using servo motors with an extended range of uSeconds.  Currently using one pot to set the target position, and the second pot to change the ramping/smoothing fraction.  Ramping/smoothing is done with a technique called easing (see here) which means continually adding a fraction-of-the-difference between target and current position.  See below, very simple…

DS1307 woes, I2C freezes and locks arduino

I've come across a problem with the DS1307 real time clock module and I thought I'd share my work around solution.