How to include previous chapter/next chapter links into each exported html file?

Hello, I’m wondering how to put links to my previous and next chapters into exported html files. I’d love it if there were some magical footer/header thing that did that automatically, but I’m not picky. Any persistent link will do.

For now let me share the manual process that has not worked. (Scrivener [])

  1. In a text document, I add text “previous chapter”
  2. Highlight the text
  3. Edit > Scrivener Link > Manuscript > [select the right link target from the tree]

That gives me a blue-highlighted link that, when viewing the document, will show the correct file in a split pane once clicked.

I’d like for that link to work when I export the files to html. The things that don’t work include:

  1. File > Export > Files…
  2. Export text files as: Web Page (.html)

That produces an html file with the text of the hyperlink (“Previous chapter”) present. But it is not a link. Inspecting it shows only a span:

<span style=" font-size:16pt;">Previous chapter</span>

Have you tried Pandoc’s ‘chunkedhtml’ output format? It will build a little website out of your single .md file that you compile from Scrivener, and is quite functional even out of the box (there are options for what heading level to split into .html files). Basic next/prev navigation comes with it, along with an “up” navigation to a ToC page it makes. I’ve made use of it for several internal projects that needed to be agile, and easy for others to read and navigate, without putting upon me a lot of design overhead.

That’s the dirt simple approach, for something much more sophisticated, there is Quarto. While that does have a learning curve, if your goal here is to publish a website—that’s a pretty enticing solution I think.

Either way, I would say in most cases these solutions are better than hard-coding navigation into the text itself, as you describe doing. Not only is that difficult in an environment that needs to “explode” one file into many somehow, but to me it just feels overly cooked into the content. I’d rather the content be inside of the navigation solution, rather than defining it directly, if that makes sense.


That was quite helpful, thanks! I have exported to mmd and used pandoc to convert to chunkedhtml. It worked really well. Do you have a good css file to recommend for fiction novels? Right now the text has no paragraph breaks or other styling. I’ll poke around but if you know of a good one I’d appreciate it.

1 Like

Glad that works for you. I’ve found it to be a real time saver ever since it was added a while back.

Right now the text has no paragraph breaks or other styling.

Oh interesting, that might have changed. The last time I used it from scratch, it had a fair bit of formatting added to it to get you started, with something that looked nice and not “default Netscape”. I then took that CSS it created (as I recall it put it into the HTML head rather than having a separate .css file), added my own tweaks and preferences, and then added to the command-line that it should use my .css file instead.

Well, if it isn’t doing that any more, that does leave one with a bit more work to do up front. As for something better for novel style typesetting, yeah I’d focus my searching on ePub author sites. Those will be the best places to find CSS oriented toward “book-ish” designs for sure. I don’t have something off-hand, but even having Scrivener compile an .epub, and then taking its .css file out of the file with Calibre or Sigil might give you a good enough start. It will have some stuff you don’t want and should remove, and the selectors will need adjustment, but that’s the easy part compared to making headings, paragraphs and such look nice in the first place.

I love all of these answers. Thanks again, you’ve gotten me headed to a good start. BTW I am using the 1.9 linux version so I’m manually doing the pandoc conversion and stuff. Probably newer scrivener does nicer things.

While the new version definitely does have better automation features, with Linux (and Scrivener v3) you do have to work around how Wine doesn’t see your Linux environment directly. You need to install Pandoc for Windows into the same prefix Scrivener is using to add integration for it, and once you do that you can automate your command-line basically. It’s pretty nice as you can save your command-line flags right into the compile settings and get the output you want with one click. If you want to do more, like chain a few commands together, then a .bat file sorts that out.

But setting up a little shell script, or even an alias, to run your preferred command-line options against the .md file is easy, too. I often prefer that as I like to use a little Ruby to orchestrate more complex post-compile setups, and while I suppose it would be possible to install Ruby into the prefix as well, it’s not something I’ve ever investigated doing as it seems like a lot of work to save just running something in a shell window after compiling. For me, that’s something I do all of the time anyway. Plus, I’m just way more familiar with Linux automation than Windows. :slight_smile:

Plus, I’m just way more familiar with Linux automation than Windows.

As am I. I haven’t used windows in 25 years. :slight_smile: That’s why I’m so pleased they released Scrivener to Linux ten years ago so I have a sane tool to use. Manuskript had some nice features but the lack of find/replace did me in.

Yeah, Manuskript has some nice things about it, like the .md storage rather than Scrivener’s whole “Markdown on top of RTF” stuff. But I found its outlining to be a bit less agile than I would desire for a writing tool. It feels more like I’m having to outline in “modes” where with Scrivener it’s all very seamless and straightforward. I guess I didn’t get far enough into it to notice that it lacked search and replace. That… seems like a critical deal breaker for sure. I hope it continues to develop though, as it is a nice idea, and it is good to see something like that available for Linux native.

I’d love to see Scrivener (3) there as well some day, but our main road block is the activation code, which is a huge mess of Windows dependencies (.NET stuff that Mono cannot address).