Get Started
Once you have the shiroa
shiroa
CLI tool installed, you can use it to create and render a book.
The shiroa init
shiroa init
command will create a new directory containing an empty book for you to get started. Give it the name of the directory that you want to create:
It will emit template files to the my-first-book
my-first-book
. Then, you can change the current directory into the new book:
There are several ways to render a book, but one of the easiest methods is to use the serve
serve
command, which will build your book and start a local webserver:
Check out the shiroa help
shiroa help
for more information about other shiroa
shiroa
commands and CLI options.
A book is built from several files which define the settings and layout of the book.
If you are familiar with mdbook
mdbook
, the book.typ
book.typ
file is similar to the book.toml
book.toml
with summary.md
summary.md
file.
The book source file is the main file located at src/book.typ
src/book.typ
. This file contains a list of all the chapters in the book. Before a chapter can be viewed, it must be added to this list.
Here's a basic summary file with a few chapters:
Try opening up src/book.typ
src/book.typ
in your editor and adding a few chapters.
The content of your book is all contained in the src
src
directory. Each chapter is a separate Typst file. Typically, each chapter starts with a level 1 heading with the title of the chapter.
The precise layout of the files is up to you. The organization of the files will correspond to the HTML files generated, so keep in mind that the file layout is part of the URL of each chapter.
All other files in the src
src
directory will be included in the output. So if you have images or other static files, just include them somewhere in the src
src
directory.
Once you've written your book, you may want to host it somewhere for others to view. The first step is to build the output of the book. This can be done with the shiroa build
shiroa build
command in the same directory where the book.toml
book.toml
file is located:
This will generate a directory named book
book
which contains the HTML content of your book. You can then place this directory on any web server to host it.
You don't have to change the default template, which already handles the HTML export. Simply set the mode
mode
to static-html
static-html
to export the book as Static HTML files:
You are viewing the HTML export of the book right now :). See the Paged version of shiroa's documentation to see the result using the old paged export.
There is still some known issues, for example, typst hasn't support labels in the HTML export yet.