The sbt-site plugin has direct support for building GitBook projects.

To enable the “sbt site GitBook” plugin in your sbt project, add the following to your project/plugins.sbt file:

addSbtPlugin("com.github.sbt" % "sbt-site-gitbook" % "1.5.0")

And enable the associated plugin in your build.sbt file:

sourceenablePlugins(SitePreviewPlugin, GitBookPlugin)

This assumes you have a GitBook project under the src/gitbook directory. To change this, set the sourceDirectory key in the GitBook scope:

GitBook / sourceDirectory := sourceDirectory.value / "doc"

Similarly, the output can be redirected to a subdirectory of target/site via the siteSubdirName key in GitBook scope:

source// Puts output in `target/site/book`
GitBook / siteSubdirName := "book"

The plugin can also be configured to manage all GitBook setup and installation by configuring a dedicated directory in which GitBook’s npm packages can be installed.

sourceGitBook / gitbookInstallDir := Some(baseDirectory.value / "node_modules" / "gitbook")