Allow Arbitrary Homepage (by Jay Pfaffman)

Well, @hellekin thought that this deserved its own topic. I’m not quite sure it’s ready for such, but here it is. I’ll have a look at stuff early next week and try to make sure that it looks like something that other people could really use. :wink:

As he said:


@pfaffman I tried to use the following setup:

  1. install your theme component
  2. set home_url_override to TransHack ·Xist·nce…
  3. add some Nginx configuration to match the HTML file:
        location = /TransHack_·Xist·nce… {
                default_type text/html;
                alias /srv/www/;

Calling the file directly works, but calling breaks. As I noticed a check on permalinks, I tried to add a permalink for /. But it did not work either. Might this be an issue with cache?

FYI, here is the content of the home.html file:

<!DOCTYPE html>
                <meta charset="UTF-8">
                <title> TransHack ·Xist·nce… </title>
                <link rel="stylesheet" href="/thx.css">
        <body class="thx home">
                <section id="agora">
                        <h2><a href="">Agora</a></h2>
                        <d-topics-list discourse-url="" per-page="5" category="1"></d-topics-list>
                <section id="fonderie-de-fiction">
                        <h2><a href="">Fonderie de fiction</a></h2>
                        <d-topics-list discourse-url="" per-page="5" category="7"></d-topics-list>
                <script src=""></script>

Edit: I guess it might be due to the fact the instance requires login (SSO), then there’s a dysfunction in this case. I might be willing to make more tests including opening the instance a bit more. After rendering the site public, I still get " Oops! That page doesn’t exist or is private." when hitting the homepage. Any idea why?


Is the home page you’re setting on your discourse site? I think you want to put just the url starting with the /.


Oh, so the file should be the default – usually index.html?

Indeed it works! The component expects the URL to be an index file, right?

I simply had to rename my home.html to index.html and change the Nginx configuration to:

        # more config...
        root   /srv/www/;
        index  index.html; # <- this is important

        location = /TransHack_·Xist·nce… {
                default_type text/html;
                alias /srv/www/; # <- and matches
        location / {
                # nginx magic to try the local file before proxying...
                try_files $uri $uri/ $uri.html @discourse;
        location @discourse {
                # normal discourse proxy

So, to summarize…

If you’re using a static page on the same site as the Discourse instance, make sure your Web server reads the static file(s) – e.g., related CSS – before proxying the requests to the Discourse. Tadaa!

Thank you @pfaffman!