--- redirect_from: - "/guide/03-build" interact_link: content/guide/03_build.md kernel_name: has_widgets: false title: |- Build HTML for each page of your book prev_page: url: /guide/02_create.html title: |- Create your book next_page: url: /guide/04_publish.html title: |- Build and publish your book online comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***" ---
Once you've added content and configured your book, it's time to
build the HTML for each page of your book. We'll use the
jupyter-book build
command-line tool for this. In the next step,
we'll stitch these HTML pages into a book.
In order to build the HTML for each page, you should have followed the steps
in creating your Jupyter Book structure. You should have
a Jupyter Book structure in a local folder on your computer, a collection
of notebook/markdown files in your content/
folder, a _data/toc.yml
file
that defines the structure of your book, and any configuration you'd like
in the config.yml
file.
Now that your book's content is in the content/
folder and you've
defined your book's structure in _data/toc.yml
, you can build
the HTML for each page of your book.
Do so by running the following command:
jupyter-book build mybookname/
This will:
_data/toc.yml
file (pointing to files in /content/
) and
do the following:nbconvert
to turn the content files (e.g., .ipynb
, .md
, etc) files into HTMLmybookname/_build/
directory.After this step is finished, you should have a collection of HTML files in your
_build/
folder.
By default, Jupyter Book will only build the HTML for pages that have
been updated since the last time you built the book. This helps reduce the
amount of unnecessary time needed to build your book. If you'd like to
force Jupyter Book to re-build a particular page, you can either edit the
corresponding file in the content/
folder, or delete that page's HTML
in the _build/
folder.
You've created your book on your own computer, but you haven't yet added it online. This section covers the steps to create your own GitHub repository, and to add your book's content to it. In this case, we'll use GitHub-Pages to build the HTML for your book. However, you can also build the book's HTML manually. Both will be covered in building and publishing your book.
First, log-in to GitHub, then go to the "create a new repository" page:
Next, add a name and description for your book. You can choose whatever initialization you'd like.
Now, clone the empty repository to your computer:
git clone https://github.com/<my-org>/<my-book-name>
Copy all of your book files and folders (what was created when you ran jupyter-book create mybook
)
into the new repository. For example, if you created your book locally with jupyter-book create mylocalbook
and your online repository is called myonlinebook
, the command would be:
cp -r mylocalbook/* myonlinebook/
This will copy over the local book files into the online book folder.
Commit the new files to the repository in myonlinebook/
:
cd myonlinebook
git add ./*
git commit -m "adding my first book!"
git push
That's it!
Now that you've created the HTML for each page of your book, it's time to stitch them together into a book. That's covered in the next section.