epubpandocepub3

How to remove epub table of contents link to title page created by pandoc


I'm playing around with pandoc as a way to create epub books. It automatically creates a table of contents by detecting all H1 tags in the book. This works well except that every epub has a TOC link to the title page, something I don't need. How do I get rid of this TOC link? Thanks, John


Solution

  • Use title in the YAML metadata block instead of a H1 for the title. For EPUB there are more specific options in the YAML block:

    ---
    title:
    - type: main
      text: My Book
    - type: subtitle
      text: An investigation of metadata
    creator:
    - role: author
      text: John Smith
    - role: editor
      text: Sarah Jones
    identifier:
    - scheme: DOI
      text: doi:10.234234.234/33
    publisher:  My Press
    rights: © 2007 John Smith, CC BY-NC
    ---
    
    my body text
    

    Note that if you're not converting from markdown, you can use --variable and --epub-metadata to pass in those values instead.

    In your case, you'll probably need to modify the incoming HTML before passing it to pandoc to remove the h1 of the title page, and pass that information on with --variable title='My Title'.

    This is because pandoc really makes a distinction between metadata (like the document title, author etc) and the document itself. So if you have a header in your document, then it also belongs in the table of contents and pandoc will put it there no matter what. (Of course, you can always go and modify the output produces by pandoc again, if you disagree with it.)