Skip to content

changing the root entry in _toc.yml has no effect at build #50

Open
@luketudge

Description

@luketudge

Describe the problem

Whereas most changes to _toc.yml (new pages, etc.) will be taken into account on a new build, changing the root entry will only take effect if the _build directory is cleared first. If not, index.html will continue to direct to the old root entry. This seems wrong or at least inconsistent.

The culprit seems to be the automatically-generated redirect file index.html that is created if the requested root file is not already named 'index'. This file persists across builds even if _toc.yml requests a different root.

Link to your repository or website

No response

Steps to reproduce

The script below runs a hopefully reproducible example showing:

  • Other changes such as adding new files work fine.
  • Changing the root entry does not.
  • Changing the root entry does work if the build cache is first cleared.
#!/bin/bash -v

#
# Create the prefab exaple book.
# Remove the example notebook (just to avoid unnecessary dependencies).
# Simplify _toc.yml.
#
rm -r mynewbook/
jupyter-book create mynewbook/
rm mynewbook/notebooks.ipynb
echo '
format: jb-book
root: intro
chapters:
- file: markdown
' > mynewbook/_toc.yml

#
# Build.
# Confirm structure of built book.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Add a new file.
#
echo '
# foo
' > mynewbook/foo.md
echo '
format: jb-book
root: intro
chapters:
- file: markdown
- file: foo
' > mynewbook/_toc.yml

#
# Confirm new file is added.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Change root file.
#
echo '
format: jb-book
root: foo
chapters:
- file: markdown
' > mynewbook/_toc.yml

#
# Confirm that changed root file does NOT register.
# Old index is used.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Finally, confirm that changed root file registers if _build cache is cleared.
#
jupyter-book clean mynewbook/
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

The version of Python you're using

3.8.10

Your operating system

Ubuntu 20.04.2

Versions of your packages

Jupyter Book      : 0.11.2
External ToC      : 0.2.2
MyST-Parser       : 0.13.7
MyST-NB           : 0.12.3
Sphinx Book Theme : 0.1.1
Jupyter-Cache     : 0.4.2
NbClient          : 0.5.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions