Templates, Foundation Code and Default Resources

Overview

An EPUB file contains a specification-defined collection of files and folders. When Steelkilt generates your EPUB, it will create numerous Resources in addition to those required to encapsulate your writing (such as XHTML Resources representing Documents and Chapters etc.)

Steelkilt also uses Templates populated with foundation XHTML and CSS code when creating Resources that represent:

  • Book title pages
  • Part title pages
  • Documents and Chapters
  • New XHTML documents
  • book.css (the CSS foundation of your EPUB)

Templates are also used each time you regenerate your EPUB.

Templates can be modified and saved, so that you can build on the foundation code or replace it entirely. You can also revert templates to discard any customizations, if necessary.

Templates and Foundation Code

Templates provide a generic framework for the markup generator that automatically converts your writing into an EPUB publication. They allow you to easily customize, with just a few edits, the appearance and features of your entire EPUB publication. Changes to a template are also written to disk, so they will affect any new Book you create. This is useful if you want all your EPUB publications to share the same appearance etc.

NameDescription
<HTML>This template is used whenever the following are generated:

  • Navigation Document (nav.xhtml)
  • Book title page (title.xhtml)
  • Part title pages
  • Document and Chapter pages
  • New XHTML pages
Edit this Resource to customize the HTML that encapsulates the content in the pages above.

If you only want to customize certain pages, then edit the HTML in those pages instead of this template.
CSSThis template provides the default CSS for your EPUB publication’s primary stylesheet (/Package/XHTML/Style/book.css).

The template contains basic styles for key HTML elements in the following:

  • Navigation document (nav.xhtml)
  • Book title page (title.xhtml)
  • Part title pages
  • Document and Chapter pages
  • New XHTML pages
To extend the collection of styles used in your EPUB publication:

  • Edit book.css; and/or
  • Add further CSS Resources to the /Package/XHTML/Style folder

Default Resources

Name/PathDescription
ContainerThis folder represents your EPUB publication’s META-INF directory.

The META-INF directory must contain a container file (container.xml). This file is created by default and includes a single <container> entry, being the XHTML rendition of your EPUB publication.

You can also add the following resources if required:

  • Encryption file (encryption.xml)
  • Manifest file (manifest.xml)
  • Metadata file (metadata.xml)
  • Rights Management file (rights.xml)
  • Digital Signatures file (signatures.xml)
Container/container.xmlThis Resource identifies the packages in your EPUB publication.

The <rootfiles> element of container.xml lists the package documents (OPF files) for each rendition of your EPUB publication.

The default rendition for your content is the XHTML rendition (described in /Package/XHTML/book.opf).

If you wish to create further renditions of your content, such as SVG, add the necessary files and directories to the Package folder, and list the OPF file(s) here.
Container/encryption.xmlThis Resource provides encryption information for the contents of your EPUB publication.

If any Resource in your EPUB publication is encrypted, this file must be present and it must provide information on how that resource is encrypted.

Consult your EPUB documentation for more information.
Container/manifest.xmlThis Resource provides a manifest of files in your EPUB publication’s container.

This Resource should not be confused with the <manifest> element in your EPUB publication’s Package document (/Package/XHTML/book.opf).

Consult your EPUB documentation for more information.
Container/metadata.xmlThis Resource encapsulates container-level metadata in your EPUB publication.

This Resource should not be confused with the <metadata> element in your EPUB publication’s Package document (/Package/XHTML/book.opf).

Consult your EPUB documentation for more information.
Container/rights.xmlThis Resource provides digital rights management (DRM) information for trusted exchange of your EPUB publication with authorized rights holders, intermediaries, and users.

Consult your EPUB documentation for more information.
Container/signatures.xmlThis Resource records the digital signatures used when signing the contents your EPUB publication.

Consult your EPUB documentation for more information.
PackageThis folder contains the files and directories that constitute each of your EPUB publication’s renditions.

The default rendition is the XHTML rendition, represented by the XHTML folder and the Package document (book.opf) within it.

To create another rendition, such as SVG, do the following:

  1. Create a top-level folder in Package
  2. Add content to the folder
  3. Create a Package document (OPF file) that lists the content and mirrors book.opf‘s metadata
  4. List the rendition’s OPF file in container.xml
Package/XHTMLThis folder represents the default rendition of your EPUB publication. It contains the following Resources:

  • Package document (book.opf)
  • Navigation Document (nav.xhtml)
  • Book title page (title.xhtml)
  • Part title pages
  • Document and Chapter pages
  • Images (extracted from Book and Part settings, and Document and Chapter content)
  • Default styles (book.css)
Each of the above is automatically generated. You can, however, lock Resources by editing them, and you can add further content where necessary.
Package/XHTML/book.opfThis Resource represents the Package document of your EPUB publication’s XHTML rendition. It is automatically generated based on your Book’s settings and the content you create.

If you edit this Resource, it will be locked. Any subsequent changes to your Book’s settings or structure will not be automatically updated until you unlock the Resource — but any customizations will be lost.

If you must customize this Resource:

  • Consider using the extensions under the Templates folder instead; and/or
  • Leaving your edits until publication time, when your content is completely final
Package/XHTML/nav.xhtmlThis Resource represents the Navigation document of your EPUB publication’s XHTML rendition. It is automatically generated based on your Book’s settings and the content you create.

If you edit this Resource, it will be locked. Any subsequent changes to your Book’s settings or structure will not be automatically updated until you unlock the Resource — but any customizations will be lost.

If you must customize this Resource, consider leaving your edits until publication time, when your content is completely final.
Package/XHTML/StyleThis folder has three purposes:

  1. It contains the default CSS styles (book.css) for your EPUB publication’s XHTML rendition
  2. It provides a common location for all CSS used in the rendition
  3. It facilitates the automatic inclusion of stylesheets in the <HTML> template, which occurs when the <%=styles%> tag in that template is replaced with a list of CSS Resource in this directory.

    Book.css will always be included during this process. Inclusion is optional for the custom CSS Resources that you add to this folder.
Package/XHTML/Style/book.cssThis Resource represents the CSS foundation of your EPUB publication. It contains basic styles for key HTML elements in the following:

  • Navigation document (nav.xhtml)
  • Book title page (title.xhtml)
  • Part title pages
  • Document and Chapter pages
  • New XHTML pages
These styles are taken from the CSS template in the Templates section.

Edit the default styles and add your own. If your changes produce an undesirable result, you can restore the default styles.
Package/XHTML/ImagesThis folder provides a common location for all images used in the XHTML rendition and facilitates some image-related tasks.

If you add a cover image to your Book or one of its Parts, the image will be stored here. Similarly, if you embed an image in the text of a Document or Chapter, it will appear here. You can also add images to this folder as required.

Once an image is in this folder, it will also appear in the Image Chooser (accessible via the Tools button on the Code Editor toolbar). From there, an image can be embedded in any Document or Chapter.

Embedding an image from this folder in some HTML code will produce an <img> tag.
Package/XHTML/Images/cover.pngThis image will be used for your EPUB publication’s cover and will also appear in the Book’s title page (title.xhtml).

To modify this image, open the Book Settings and use the controls in the “Cover image” section.
Package/XHTML/Images/<part-name>.pngThis image will appear in the following Part’s title page:

<part-name>

To modify this image, open the Part’s Settings and use the controls in the “Image” section.
Package/XHTML/title.xhtmlThis Resource represents your EPUB publication’s title page.

Its markup is generated from your Book Settings.
Package/XHTML/<part-name>This Resource represents the title page for the Part of the same name.

The markup in this page is generated from the Part’s Settings.
Package/XHTML/<document-or-chapter-name>.xhtmlThis Resource represents a Document or Chapter that is not contained within a Part.

The markup in this Resource is generated from the text in the Document or Chapter of the same name.
Package/XHTML/<part-name>/<document-or-chapter-name>.xhtmlThis Resource represents a Document or Chapter that is contained within a Part.

The markup in this Resource is generated from the text in the Document or Chapter of the same name.

Regeneration

To regenerate the content of your EPUB:

  • Select the any of the Default Resources (listed in the table above)
  • Tap on the Tools button in the toolbar
  • Choose Regenerate

Note

The Tools button will be disabled for locked Resources.

Read the following for more information about Resource locking:

Reverting Templates and Foundation CSS

To discard any customizations to Templates or book.css:

  • Select a Template or book.css
  • Tap on the Tools button in the toolbar
  • Choose Revert to Default

Related Concepts