Search code examples
androidhttp-redirectmobileblogger

How can I redirect my users to a specific label when they visit my blog?


I'm starting a new blog and I want to streamline things for mobile users. How can I detect mobile users and redirect them to an specific label on my blog?

I searched around in the settings of blogger and the only thing that caught my attention really was the option to edit the html. I really have no clue what to do there to be honest though if thats what I need to edit.


Solution

  • You can use Blogger code data:blog.isMobileRequest and javascript.

    <b:if cond='data:view.isHomepage and data:blog.isMobileRequest'>
    <script>
    var $tag = "YOUR_TAG";
    document.location = document.location.origin + "/search/label/" + $tag;
    </script>
    </b:if>
    

    Edit HTML and put the code after <head> then save the template.

    The code checks if the URL has parameter m=1 then it redirects to the chosen tag, and it only redirect home page url to prevent multiple redirects.