Part 14: use my example OPF template to add an OPF file to your own ebook.
You might be excused for thinking that you’ve finished coding your ebook. However, first you have to compile two small files and your cover image, which you will place in the same folder as your ebook HTML file, to generate a MOBI suitable for uploading to Kindle.
The OPF is a metadata file which contains data about the ebook itself. Like the HTML file, I’ve included an example OPF with some annotated notes below. Download it (right click on the link → save link as), unpack it with WinRAR or a similar utility and open the OPF file in Notepad++ by dragging it across.
Disclaimer: my understanding of the OPF file and its gruesome innards is slightly shaky. I used the above example to generate an ebook with no warning messages, but I do apologise in advance if this doesn’t completely fill you to the brim with confidence. I have found some great links dealing with the subject in more detail, including articles by Dave Cassler (which I found to be a real soft landing on the subject), George Benthien and Helen Hanson.
Exploring the OPF example template
You can adapt this entire file for your ebook (by saving it as yourbooktitle.opf), taking care to make changes to the following lines:
Line 1: These values set certain XML standards. You may see other values on other OPF files. Which is better? I’m not even sure the experts can agree.
Line 6: Your own book title goes here.
Line 7: Geaorge Benthien provides a list of acceptable language codes.
Line 8: Cut and paste, except that you can generate your own UUID string to replace
Lines 9-10: Modify to suit.
Lines 11-13: The BASIC (actually, the correct acronym is BISAC, but it seems to feature in OPF files as BASIC) is the Book Industry Standards and Communications code, a series of identifiers similar to the Dewey system which categorise books by subject. You can find the relevant BISAC code lists here, and select up to three to match your book’s subject.
Line 14: You can also have up to three description entries here, but each must be under 255 characters long (or they are truncated at 255 characters exactly).
Line 15: date of publication in
YYYY format only.
Line 18: although we have not talked about book covers yet, you can insert the filename of your book cover, in JPG format, here (or come back and do it later).
Line 23: insert your HTML filename here as the
Line 24: insert your cover image filename here as the
Line 25: coding your NCX will be the next step, but let’s assume that you’ll name it yourbooktitle.ncx, in which case you can insert the value here.
Lines 33-4: your HTML filename will have to be inserted to both of these lines as the
href="" value, to replace my novel’s name. Can you see how this is linking the Kindle’s understanding of where the novel starts and the table of contents to the appropriate places in your ebook?
That’s it. Save the OPF, and we’ll move on to coding the NCX file in the next article.
Proceed to Part 15: ‘Preparing the NCX file’, or return to the article index.
While I’ve endeavoured to provide you with accurate information, what is considered ‘accurate’ will change over time. If I’m wrong, or you’d like to ask a question or share your thoughts, I’d love to hear your take on things.