https://discuss.asciidoctor.org/How-to-create-a-custom-backend-tp2494p2617.html
Eirik,
I'll start by saying that I'm well aware we need better documentation for how to create custom backends. When I finally get a chance to focus on writing, it's near the top of the list.
Fortunately, there are lots of developers playing around with backends, so we have no shortage of good examples.
The asciidoctor-backends repository is a collection of template-based converters. There is one template file per node (though you can structure it however you'd like). If a template file is missing for a node, Asciidoctor falls back to the built-in handler for that node, so you only have to implement templates for nodes you want to customize.
We maintain a complete set of templates for the built-in converters here:
(Thanks to Jakub for creating a test suite to ensure these are up to date).
The downside of the template-based converters is that it doesn't give you control to write multiple files from a single AsciiDoc document. Instead, you are merely customizing the sections of the single file that is generated by default.
If you want to produce multiple files from a single input file, then you need to implement a custom Ruby-based converter. There's almost no limit to what you can do once you create a custom converter in Ruby, though there are far less examples for doing so.
What you'll actually do is create a convert that implements the Writer interface. The Writer interface allows you to control when files are written to disk, which is when you can produce multiple files. I would start by playing around with that gist and see how far you get. If you have questions, feel free to ask. Your use case could certainly help me with knowing how to write the docs for it.
It is possible to combine a Ruby-based converter with a template-based converter, though that's probably a more advanced topic ;)
In the end, I want you to think of an AsciiDoc document as a flat database of content. From it, you can produce one file or many. The goal of the converter and extension APIs is to allow you to produce exactly what you want to produce. In other words, a total separation of content and presentation / publishing.
Cheers!
-Dan