Hans, Since I didn't got a working epub for the first few tries, I did some further inspections with epubcheck[1]. Using this minimal example: \setupbackend[export=test.xml,xhtml=test.xhtml,css={test.css,mathml.css}] \starttext Test \stoptext The main errors are: * opf: id has to be either "stylesheet" for css or the xhtml filename without the suffix * opf: itemref needs to be the name of the xhtml without the suffix Here's a very dirty quick fix I did to get a working epub: add after line 112 or so: + local id = file.removesuffix(filename) line 116: - used[#used+1] = format("<item id='%s' href='%s' media-type='%s'/>",i,filename,mime) + if suffix == "css" then + id = "stylesheet" + elseif suffix == "ncx" then + id = file.suffix(filename) + end + used[#used+1] = format("<item id='%s' href='%s' media-type='%s'/>",id,filename,mime) line 121: - package = format(package,identifier,identifier,concat(used,"\n"),root) + package = format(package,identifier,identifier,concat(used,"\n"),file.removesuffix(root)) I'm sure you make a better fix (I've attached the patched one in case it's easier to diff). Not sure if you want to do something about the other errors, but it'd be nice to have a valid epub in the end. Adam [1] http://code.google.com/p/epubcheck/