ePUB

Output a .epub file with the site

Options

output string

File to output the .epub file

Default:
"/book.epub"
outputUncompressed boolean

Set true to output also the pages (for debuging purposes)

Default:
false
metadata object

Metadata of the book

identifier string

Unique identifier for the package

Default:
"urn:uuid:00000000-0000-0000-0000-000000000000"
title string

Title of the publication

Default:
"Untitled"
subtitle string

Subtitle of the publication

cover string

File with the cover image

creator union[]

The creators of the publication

subject string[]

The subjects of the publication, including an arbitrary phrase or keyword

description string

Description of the publication's content.

publisher string

Name of the publisher

Default:
"Unknown"
contributor union[]

Names of contributors to the publication

date object

Date of publication

Default:
2026-03-11T19:45:01.712Z
language string

Language of the publication

rights string

A statement about rights, or a reference to one.

Default:
"All rights reserved"

Description

This plugin converts the site to EPUB, the standard format for ebooks. Specifically, it's responsible for:

  • Creating the container.xml, encryption.xml, mimetype, and content.opf manifest files.
  • Creating the toc.ncx file with the book structure (using the nav plugin under the hood).
  • Converting the code and change the extension of all .html pages to .xhtml.
  • Compressing all files and create the book.epub file in the dest folder.

Installation

Import this plugin in your _config.ts file to use it. The plugin needs the metadata configuration with the info of your book that will be used to create the content.opf manifest file:

import lume from "lume/mod.ts";
import epub from "lume/plugins/epub.ts";

const site = lume({
  prettyUrls: false, // prettyUrls don't make sense for ebooks
});

site.use(epub({
  // Book metadata
  metadata: {
    identifier: "unique identifier of your book",
    cover: "/images/cover.png",
    title: "My awesome book",
    subtitle: "History of my life",
    creator: ["Óscar Otero"],
    publisher: "Lume editions",
    language: "en-US",
    date: new Date("2026-01-31T12:18:28Z"),
  },
}));

export default site;

Output uncompressed

Technically, the ePUB format is a zip file but with the .epub extension. So you can uncompress the epub with any unzip utility and inspect the content. For convenience, the plugin provides the outputUncompressed option to save also the uncompressed pages for inspection:

site.use(epub({
  outputUncompressed: true, // Output the uncompressed files
}));