HUGO

Generate Hugo Website as E-Book (epub)

The widely used e-book file format epub is actually just a zip folder with a fixed structure of XHTML files, images and some metadata. That’s why I came up with the idea to develop a HUGO theme that creates an e-book directly from the HUGO content folder without further manual intervention. This makes it possible, for example, to easily offer an existing HUGO blog for download as an e-book or to convert Markdown formatted texts directly into cleanly formatted, valid e-books.

So far the documentation is unfortunately only available in German language. If it is useful for other people, I will translate it into English. But the theme is mostly self-explanatory:

  • Just download and unpack.
  • The theme is ready to run immediately. The call of “hugo” in the HUGO root directory creates the demo e-book in the public folder – but unpacked yet.
  • To get the desired epub format, the content of the public folder has to be zipped. The zip archive must have the extension .epub. Done!
    Important: the file mimetype must be the first file in the zip archive. So the call of “zip” should (e.g.) be like this …
# hugo
# cd public
# zip -rX ../ebook.epub mimetype OEBPS META-INF

… to create an e-book named ebook.epub, which is located in the HUGO root directory

  • To avoid file garbage in the e-book, the files in public-folder and the zip/epub file should be deleted before the e-book is recreated. For Linux a deploy bash script is part of the theme, which does all steps automatically.
  • In order to create your own e-book, you only need to adjust the metadata in config.toml and replace the page resources in the content/posts/ folder with your own content in markdown format.
  • In addition, the file static/OEBPS/cover.jpg should be exchanged with your own cover (ideally in portrait format).

Download HUGO epub theme

Documentation (in German)

16 Likes

The switch --cleanDestinationDir can take care of that.

4 Likes

Nice project: have you the project to translate the documentation in English?

Maybe the translation of GoogleTranslate of this article is already enough for you? I will wait with the translation for a while, if there are still bugs or ideas for improvement.

1 Like

Hi, thanks a lot for sharing this interesting project! Do you have a github repo to follow the changes/improvents of the theme?

not yet.