What’s in an ePUB?: The OPF File

The OPF file is located within the OPS folder. ‘OPF’ stands for Open Package Format. It’s essentially an XML file, although it has the file extension .opf instead of .xml. It lists all of the contents of your ePUB, and tells the reading system what order to display the files in.

OPS folder which lists xhtml files, css, fonts and images folders, and the package.opf file which is selected in the screenshot

There are five parts to the OPF:

1. The XML doctype

two lines of code relating to xml and the package

The first line of the doctype tells the machine that is reading the file that it is in XML, and the second tells it where to go to find the rules of this particular type of XML (the OPF standard on the IDPF website).

The unique identifier in the OPF must match the unique identifier in the metadata below. You can use the ISBN of the book that you are creating as the identifier, or you can use the generic “book-id”.

2. The Metadata

Lines of code pertaining to the ebook metadata including title, date, creator, identifer, and language

This section contains the basic metadata about the book. It is different from the metadata that you send via ONIX feed, or fill out in an Excel template. This section within the ePUB just contains some very basic information. The only five lines that you really need in the metadata are the title, publication date, book-id, language and the date the file was last modified. If your book has accessibility features, that metadata is also listed here.

3. The OPF Manifest

The manifest is an unordered list of all of the files within the OEBPS/OPS directory.  Each item in the manifest has three components

  1. An item ID, which you can make up, and should describe the file.

shows the following code: <item id="cover"

2. A reference to the actual file.

shows the following code: href="cover.xhtml"

3. The media-type, which tells the parser what type of file it is.

shows the following code: media-type="application/xhtml+xml"/>

Things that should be included in the manifest:

  • Fonts
  • All of the XHTML pages in the book (introduction, copyright, chapters, epigraph, etc.)
  • Images
  • Audio or Video files, if applicable
  • The CSS stylesheet
  • The NCX file, if you’re working with the ePUB 2.0 format

You can leave out the OPF itself, the META-INF, and the mimetype.

Here is an example of a manifest:

ePUB manifest listing fonts, table of contents, copyright, titlepage, cover, style, chapters, etc., as items under a <manifest> tag

4. The Spine

The spine is an ordered list of all of the contents of the book. It uses the item IDs you’ve created in the manifest. Each item gets an item ref, and you use the item id that you created in the manifest for the id ref.

shows the following code: <itemref idref="cover" />

Here’s an example of a spine:

epub spine showing itemrefs including cover, titlepage, brief-toc, preface, introduction, epigraph, and chapters 1 to 5

The spine does not need to include images, CSS, audio/visual files, or fonts. If you are working with ePUB 2.0, you should include the NCX file at the beginning of the spine, though.

5. The Guide

The guide points the reading system to the main content in the book. Typically, the guide includes the cover, the table of contents, and the beginning of the actual text. The guide section is deprecated in ePUB 3.0, but some vendors still use it.

epub guide coding with two reference tags for cover and table of contents

Tags

Latest Resources

Need help with alt text?

If you're taking on the task of writing your own alt text, you may feel a bit overwhelmed—but eBOUND is here to help! Below is a downloadable template you can use with a few examples. You can use...