How to default to latest on mobile and categories+latest on desktop?

AI-generated summary

The discussion revolves around the possibility of defaulting to the “latest” page on mobile devices while maintaining the “categories+latest” combined view on desktops. codinghorror initially states that it is not possible, but Lutz provides a workaround by editing nginx settings using a reverse proxy. Lutz shares code examples for this approach.

Alternatively, david proposes a compromise solution, which involves setting categories as the homepage and making the logo link to the “latest” page on mobile devices. david shares the code used to implement this solution.

scombs suggests introducing an admin setting for mobile category page style, which would complement the existing setting for desktop category page style. _vincent bumps this feature request, citing the increasing importance of mobile usage in their community and the need for a more pleasant mobile experience when using the “categories+latest” combined view.

Is there a way to default the frontpage to display latest page on mobile, while on desktop displaying the categories+latest combined view? I’m currently trying to figure this out.

No there is no way to do this.

Thanks. That’s a bit sad tho as I am finding it frustrating to have to take an extra step to find latest when on mobile and using the discourse app. It tells me I have new posts to read, I select the link and then see not topics but categories. On desktop I am ok with the cat+latest view which my colleagues prefer but on mobile it shows me just cat.

You could do it, if you edit the nginx-settings. We use a nginx reverse proxy, so its no real problem. Its a dirty hack, but works.

    # ---------------------------------------------------------------------------------
    # Redirect Mobile to latest instead to default
    # ---------------------------------------------------------------------------------
        set $mobile_rewrite N;
        if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
               set $mobile_rewrite Y;
        }
        if ( $http_referer !~* "www\.mydomain\.com" ) {
               set $mobile "${mobile_rewrite}E";
        }
        if ($mobile_rewrite = YE) {
               rewrite     ^\/$   https://www.mydomain.com/latest redirect;
        }
        if ($http_user_agent ~* '(iPhone|iPod|android|blackberry)') {
             rewrite     ^\/$   https://www.mydomain.com/latest permanent;
        }

This version is shorter and faster, may also work for you. [code] if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") { rewrite ^\/$ https://www.mydomain.com/latest redirect; } [/code]

The compromise we reached on our forum was to

  • Set categories as the homepage
  • On mobile, make the logo link to /latest

That way the categories view is welcoming to potentially new visitors, while regular users are just 1 tap away from the ‘latest’ page.

The suggestion came from somewhere on meta, but I can’t find it right now.

The code we use (in the Mobile “Header” section of CSS/HTML customisation) is

<script type="text/discourse-plugin" version="0.4">
  api.changeWidgetSetting('home-logo', 'href', '/latest')
</script>

(on an unrelated note, can json uploads be enabled on meta, so we can share “exported” customisations for others to easily import?)

Definitely in favor of a admin setting for

  • mobile category page style

To go along with the current setting for

  • desktop category page style

Categories+Latest combined view is brilliant for desktop but Latest is key for mobile.

Bumping this feature request:

Mobile usage is more and more frequent on my community, and I too think the default mobile view is pretty unpleasant when using Categories + Latest as the category page style.