This repository is a ready-to-use template for efficiently writing, organizing, and publishing books with modern
tooling. It includes a structured directory layout, powerful automation scripts, and full integration
with Poetry via a pyproject.toml
configuration.
Authors can easily create, format, and export books in multiple formats like PDF, EPUB, MOBI, and DOCX.
- π Structured Directory: Predefined folders for chapters, front matter, back matter, and assets
- π Markdown-Based Writing: Compose in Markdown for clarity and compatibility
- π Automated Conversion: Generate multiple output formats via Pandoc
- π Dynamic Table of Contents: Keep your structure organized and current
- π Metadata Automation: Easily inject book metadata with a script
- π Git Integration: Seamless GitHub usage for versioning and collaboration
- π§° Poetry Integration: Dependency and script management powered by Poetry
- Click on the green
Use this template
button at the top of this repository page. - Choose
Create a new repository
and name your book project. - Clone it locally:
git clone https://github.com/YOUR_USERNAME/YOUR_BOOK_REPO.git
cd YOUR_BOOK_REPO
β οΈ Note: The shell scriptscripts/create_project_structure.sh
is now deprecated and will be removed in the future.
β Please use the Python script with Poetry integration instead.
Run the following command to create the complete folder structure and all required files:
poetry run init-book-project
This will:
-
Create all necessary folders (
manuscript/
,config/
,assets/
,output/
, etc.) -
Generate chapter and front/back matter files
-
Create
metadata.yaml
andmetadata_values.json
with placeholders -
Add a template for image generation prompts (
scripts/data/image_project_config.json
) -
Prepare the project for exporting and translation
π Full guide available here:
π π¦ Project Initialization β Wiki
This project is configured with Poetry. To install dependencies and use the automation scripts:
poetry install
Available scripts (defined in pyproject.toml
):
poetry run update-metadata-values
β injects structured metadata into your YAML filepoetry run full-export
β exports your book to multiple formatspoetry run print-version-build
β prints current version/build info
Replace placeholders in config/metadata.yaml
using this command:
poetry run update-metadata-values
This method ensures your virtual environment is used correctly and dependencies are managed by Poetry.
- Loads metadata values from
config/metadata_values.json
- Replaces all placeholders like
{{BOOK_TITLE}}
inmetadata.yaml
with actual content - Properly formats lists such as
KEYWORDS
andOUTPUT_FORMATS
to YAML list syntax - Automatically deletes the
metadata_values.json
file after successful population - Logs success and error messages to the console
π Learn how this works in detail in the Medium article
After running the Python script, metadata.yaml
will look like this:
title: "Your Book Title"
subtitle: "A short subtitle describing your book"
author: "Your Name"
isbn: "Your ISBN Number"
edition: "Your Edition (e.g., 1st Edition, 2nd Edition)"
publisher: "Your Publisher Name"
date: "YYYY-MM-DD"
language: "en"
description: "Provide a detailed description of your book."
keywords:
- "AI"
- "machine learning"
- "automation"
cover_image: "assets/covers/cover.jpg"
output_formats:
- "pdf"
- "epub"
- "mobi"
kdp_enabled: true
Once your book is written, export it:
poetry run full-export
The generated files will be available in the output/
folder.
Commit and push your changes manually to GitHub:
git add .
git commit -m "Add new content or update chapters"
git push
- Add chapters in
manuscript/chapters/
- Edit
manuscript/front-matter/toc.md
for your table of contents - Add illustrations or diagrams under
assets/
The full documentation is available in the Wiki.
Here are the main sections to get you started:
- Translate Markdown with DeepL
- Translate with LM Studio
- Translation CLI Commands & Shortcuts
- Shortcuts for Translation
- Automatically Export Book
- Shortcuts for Export
- Export HTML Chapters from Your Comic
- Export to EPUB 2
- Exporting HTML Books to PDF with Puppeteer (KDP Ready)
write-book-template/
βββ manuscript/
β βββ chapters/
β β βββ 01-introduction.md
β β βββ 02-chapter.md
β β βββ ...
β βββ front-matter/
β β βββ toc.md
β β βββ preface.md
β β βββ foreword.md
β β βββ acknowledgments.md
β βββ back-matter/
β β βββ about-the-author.md
β β βββ appendix.md
β β βββ bibliography.md
β β βββ faq.md
β β βββ glossary.md
β β βββ index.md
β βββ figures/
β β βββ fig1.png
β β βββ fig2.svg
β β βββ ...
β βββ tables/
β β βββ table1.csv
β β βββ table2.csv
β β βββ ...
β βββ references.bib # If using citations (e.g., BibTeX, APA, MLA formats supported)
βββ assets/ # Images, media, illustrations (for book content, cover design, and figures)
β βββ covers/
β β βββ cover-design.png
β βββ figures/
β β βββ diagrams/
β β βββ infographics/
βββ config/ # Project configuration (metadata, styling, and optional Pandoc settings)
β βββ metadata.yaml # Title, author, ISBN, etc. (used for all formats: PDF, EPUB, MOBI)
β βββ styles.css # Custom styles for PDF/eBook
β βββ template.tex # LaTeX template (if needed)
βββ output/ # Compiled book formats
β βββ book.pdf
β βββ book.epub
β βββ book.mobi
β βββ book.docx
βββ scripts/ # Scripts and tools (initialize project, convert book, update metadata, and export formats)
β βββ convert_book.sh # Converts Markdown to multiple formats
β βββ convert_img_tags.sh # Converts the paths of the img tags
β βββ convert_to_absolute.sh # Converts the relative paths to absolute paths of the md images
β βββ convert_to_relative.sh # Converts back the absolute paths to relative paths of the md images
β βββ create_project_structure.sh # Initializes project structure
β βββ full_export_book.py # Exports book to all publishing formats with backup
β βββ metadata_values_example.json # example metadata values json file
β βββ update_metadata_values.py # Automates metadata population
βββ LICENSE # If open-source
βββ pyproject.toml # Configuration file for poetry
βββ README.md # Project description
- Metadata: Modify
config/metadata.yaml
to personalize your book details (title, author, etc.) - Styles: Edit
config/styles.css
to tailor your bookβs appearance and formatting. - Scripts: Customize conversion settings and output options as needed.
- Poetry (for managing this Python project)
- Python 3.x (for advanced automation with
full_export_book.py
) - Pandoc for manuscript conversion.
- Calibre specifically for MOBI conversions.
- GitHub CLI (
gh
) for managing repositories (optional but recommended).
Refer to Full Export Documentation for detailed error handling and solutions regarding export scripts.
Found a bug or want to contribute? Pull requests and suggestions are welcome!
Released under the MIT License. Please see the LICENSE
file for details.
π Happy writing! Start your book today!