Repository: sphinx-doc/sphinx

Issue:
sphinx-quickstart creates non-satisfying html default set-up with Alabaster
I tested 1.7.5 and current master, both consider ``'alabaster'`` to be default HTML theme, but the `conf.py` is ill-configured for them and creates un-navigable documents.

For example, this:

![capture d ecran 2018-06-09 a 15 27 38](https://user-images.githubusercontent.com/2589111/41192121-b0f356b0-6bf9-11e8-983c-1cdc4a1f405e.png)

with an `index.rst` like this

```rst
.. toctree::
   :maxdepth: 2

   foo1
   foo2
```

There is no link to go back to table of contents or to foo1 page.

#### Expected results

Things should work out-of-the box. It does not make sense to make default ``alabaster`` and not provide correct set-up to use it.


### Environment info
- OS: Mac
- Python version: 3.6.5
- Sphinx version: 1.7.5 and master
- Alabaster theme 0.7.10

Relates:

#3830, #4496, #3849, #3987, #4002 and probably others. Edit: #4177

I know this has been issued many times and I did personally at least two commits to fix it but it always end up overridden in some way. So I would really like this to be fixed once and for all.

Update: later investigation in my comments below reminded me #4177 should have fixed this, but there is a problem remaining when theme does not provide sidebars config in theme.conf.

Discussion:

Patch:
diff --git a/CHANGES b/CHANGES
index 2074d06ea..2d896a3e8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -29,6 +29,7 @@ Bugs fixed
 * #5019: autodoc: crashed by Form Feed Character
 * #5032: autodoc: loses the first staticmethod parameter for old styled classes
 * #5036: quickstart: Typing Ctrl-U clears the whole of line
+* #5066: html: "relations" sidebar is not shown by default
 
 Testing
 --------
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index fad49486b..f43ac0e4f 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -906,19 +906,27 @@ def add_sidebars(self, pagename, ctx):
         def has_wildcard(pattern):
             # type: (unicode) -> bool
             return any(char in pattern for char in '*?[')
-        sidebars = self.theme.get_config('theme', 'sidebars', None)
+        sidebars = None
         matched = None
         customsidebar = None
 
         # default sidebars settings for selected theme
-        theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
-        if theme_default_sidebars:
-            sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
-        elif self.theme.name == 'alabaster':
+        if self.theme.name == 'alabaster':
             # provide default settings for alabaster (for compatibility)
             # Note: this will be removed before Sphinx-2.0
-            sidebars = ['about.html', 'navigation.html', 'relation.html',
-                        'searchbox.html', 'donate.html']
+            try:
+                # get default sidebars settings from alabaster (if defined)
+                theme_default_sidebars = self.theme.config.get('theme', 'sidebars')
+                if theme_default_sidebars:
+                    sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
+            except Exception:
+                # fallback to better default settings
+                sidebars = ['about.html', 'navigation.html', 'relations.html',
+                            'searchbox.html', 'donate.html']
+        else:
+            theme_default_sidebars = self.theme.get_config('theme', 'sidebars', None)
+            if theme_default_sidebars:
+                sidebars = [name.strip() for name in theme_default_sidebars.split(',')]
 
         # user sidebar settings
         for pattern, patsidebars in iteritems(self.config.html_sidebars):


Test patch:
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index bbfd0bc90..fd599c703 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -1230,21 +1230,50 @@ def test_html_remote_images(app, status, warning):
 
 @pytest.mark.sphinx('html', testroot='basic')
 def test_html_sidebar(app, status, warning):
+    ctx = {}
+
+    # default for alabaster
     app.builder.build_all()
     result = (app.outdir / 'index.html').text(encoding='utf8')
-    assert '<h3><a href="#">Table Of Contents</a></h3>' in result
+    assert ('<div class="sphinxsidebar" role="navigation" '
+            'aria-label="main navigation">' in result)
+    assert '<h1 class="logo"><a href="#">Python</a></h1>' in result
+    assert '<h3>Navigation</h3>' in result
     assert '<h3>Related Topics</h3>' in result
-    assert '<h3>This Page</h3>' in result
     assert '<h3>Quick search</h3>' in result
 
+    app.builder.add_sidebars('index', ctx)
+    assert ctx['sidebars'] == ['about.html', 'navigation.html', 'relations.html',
+                               'searchbox.html', 'donate.html']
+
+    # only relations.html
+    app.config.html_sidebars = {'**': ['relations.html']}
+    app.builder.build_all()
+    result = (app.outdir / 'index.html').text(encoding='utf8')
+    assert ('<div class="sphinxsidebar" role="navigation" '
+            'aria-label="main navigation">' in result)
+    assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
+    assert '<h3>Navigation</h3>' not in result
+    assert '<h3>Related Topics</h3>' in result
+    assert '<h3>Quick search</h3>' not in result
+
+    app.builder.add_sidebars('index', ctx)
+    assert ctx['sidebars'] == ['relations.html']
+
+    # no sidebars
     app.config.html_sidebars = {'**': []}
     app.builder.build_all()
     result = (app.outdir / 'index.html').text(encoding='utf8')
-    assert '<h3><a href="#">Table Of Contents</a></h3>' not in result
+    assert ('<div class="sphinxsidebar" role="navigation" '
+            'aria-label="main navigation">' not in result)
+    assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
+    assert '<h3>Navigation</h3>' not in result
     assert '<h3>Related Topics</h3>' not in result
-    assert '<h3>This Page</h3>' not in result
     assert '<h3>Quick search</h3>' not in result
 
+    app.builder.add_sidebars('index', ctx)
+    assert ctx['sidebars'] == []
+
 
 @pytest.mark.parametrize('fname,expect', flat_dict({
     'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),