Different landing page for desktop vs mobile theme?

I originally found this topic when searching for a solution to my problem:

As it explains, I have my forum set up to display categories + latest since I don’t only want to display the latest on desktop. Here are the two Discourse settings that make that layout possible:

It’s the ideal layout for me since it both displays the categories for users looking to post something new and makes the latest available for other people who are just coming back to see what’s new.

For anyone reading along who wants to do the same thing, here’s what you need to do:

  1. Go to the Edit CSS/HTML section of your theme:

  2. Add the following script in the MobileHeader section (so it only affects visitors on mobile devices):

    Here’s the script so you can copy/paste it:

    <script>
        if (window.location.pathname == "/")
        {   window.location.href = "/latest";
        }
    </script>
    
    <script type="text/discourse-plugin" version="0.4">
        api.changeWidgetSetting('home-logo', 'href', '/latest')
    </script>
    

Update: The Forced Mobile Homepage theme component linked above is probably a better way to accomplish this.

10 Likes