4. Template Book#

We created a GitLab template repository containing an appropriate folder structure and template versions of the files you will need for your JupyterBook. You can start with a copy of this repository, add your content files and adjust the configurations.

4.1. Content#

You can store your MarkDown files with content in the folder called content. In the template book, this folder contains two templates: template-chapter.md and template-subchapter.md for your content. Each MarkDown file will eventually be one webpage in your JupyterBook, take this into account when you divide your content over the MarkDown files. For more examples of what features you can include in your content, you can check out our demobook.

4.2. Requirements file#

The requirements.txt file should contain a list of the libraries, modules, and packages that are required for your book. The packages myst_nb and jupyterquiz are required for building a jupyter book from MarkDown of Jupyter Notebook files. Additionally, other Sphinx modules that are used in your book should be included, such as sphinx-exercise, sphinx-proof and sphinx-inline-tabs. If you include Python code cells using libraries, such as numpy, scipy, matplotlib and plotly, they should be part of your requirements.txt file as well.

4.3. Table of content file#

You can structure your content for your Jupyter Book using the YAML table of content file (_toc.yml). Our template _toc.yml file provides default settings for creating a new book, which you should modify to include your content. Detailed information on how to do this can be found in a tutorial on the website of JupyterBook

4.4. Configuration file#

You can configure your Jupyter Book using the YAML configuration file (_config.yml). This file controls a number of options and feature flags. Detailed information can be found in a tutorial on the website of JupyterBook

This section is a reference for the _config.yml structure of our template implementation and how it should be changed when creating a new book.

Caution

YAML can be tricky when it comes to how it treats certain kinds of values. For example, when using strings in YAML, it is usually fine to omit quotation marks around them. However, there are certain values that will be converted to boolean values if they do not have strings around them, for example, false, true, off, etc. In addition, pure numbers will be converted to float or int unless you put strings around them.

Our template _config.yml file provides default settings for creating a new book, which you can modify if necessary. These parameters are marked with an asterisk (*) in the following parameter lists and with the phrase Change this parameter in the _config.yml file for easy reference.

4.4.1. Book settings#

All the basic information regarding the book.

# Book Settings
title: "Template Jupyter Book" 
author: Your Name 
description: This is the template book for everyone that wants to create a new Jupyter Book from scratch. 
copyright: Delft University of Technology, CC BY-SA 4.0
logo: content/images/tudelft.png
exclude_patterns: [ _build, Thumbs.db, .DS_Store, "**.ipynb_checkpoints" ]

# Only build files in the ToC to avoid building README, etc.
only_build_toc_files: true

4.4.2. Execution settings#

No need to change anything. More information at: Execute and cache your pages.

# Execution Settings
execute:
  execute_notebooks: force
  cache: ""
  exclude_patterns: [ ]
  timeout: 30
  run_in_temp: false
  allow_errors: false
  stderr_output: show

4.4.3. Parse and render settings#

No need to change anything. More information at: Syntax Extensions.

# Parse and Render Settings
parse:
  myst_enable_extensions:
    - amsmath
    - colon_fence # To allow for ::: instead of ``` blocks.
    - deflist
    - dollarmath
    - html_admonition
    - html_image
    - linkify
    - replacements
    - smartquotes
    - substitution
    - tasklist
  myst_url_schemes: [ mailto, http, https ]
  myst_dmath_double_inline: true

4.4.4. HTML-Specific Settings#

# HTML-specific settings
html:
  favicon: "content/images/favicon.ico"
  use_edit_page_button: true
  use_repository_button: true
  use_issues_button: false
  use_multitoc_numbering: true
  extra_navbar: ""
  extra_footer: ""
  google_analytics_id: ""
  home_page_in_navbar: true
  baseurl: ""
  comments:
    hypothesis: true
    utterances: false
  announcement: ""

4.4.5. LaTeX-specific settings#

# LaTeX-Specific Settings
latex:
  latex_engine: pdflatex
  use_jupyterbook_latex: true
  latex_documents:
    targetname: book.tex

4.4.6. Launch button settings#

No need to change anything.

# Launch Button Settings
launch_buttons:
  notebook_interface : classic

4.4.7. Information about where the book exists on the web#

# Information about where the book exists on the web
repository:
  url: https://gitlab.tudelft.nl/opentextbooks/how-to-manual/
  path_to_book: ""
  branch: master

4.4.8. References#

No need to change anything.

# Add a bibtex file so that we can create citations
bibtex_bibfiles:
  - references.bib

4.4.9. Advanced and power-user settings#

No need to change anything.

# Advanced and power-user settings
sphinx:
  extra_extensions: [...]
  local_extensions: [...]
  recursive_update: false
  config: [...]