diff --git a/book/.gitignore b/book/.gitignore
index 690b5b80..72775071 100644
--- a/book/.gitignore
+++ b/book/.gitignore
@@ -1,2 +1,3 @@
/build
/mdbook
+/node_modules
diff --git a/book/build.js b/book/build.js
new file mode 100755
index 00000000..a9278db8
--- /dev/null
+++ b/book/build.js
@@ -0,0 +1,37 @@
+#!/usr/bin/env node
+
+const fs = require('fs');
+const cheerio = require('cheerio');
+
+const githublink = `\
+
\
+\
+\
+https://github.com/dtolnay/cxx\
+\
+`;
+
+const dirs = ['build'];
+while (dirs.length) {
+ const dir = dirs.pop();
+ fs.readdirSync(dir).forEach((entry) => {
+ path = dir + '/' + entry;
+ const stat = fs.statSync(path);
+ if (stat.isDirectory()) {
+ dirs.push(path);
+ return;
+ }
+
+ if (!path.endsWith('.html')) {
+ return;
+ }
+
+ const index = fs.readFileSync(path, 'utf8');
+ const $ = cheerio.load(index, { decodeEntities: false });
+
+ $('nav#sidebar ol.chapter').append(githublink);
+
+ const out = $.html();
+ fs.writeFileSync(path, out);
+ });
+}
diff --git a/book/build.sh b/book/build.sh
index a8471396..783d304b 100755
--- a/book/build.sh
+++ b/book/build.sh
@@ -9,3 +9,9 @@ if [ -f ./mdbook ]; then
else
mdbook build
fi
+
+if [ ! -d node_modules ]; then
+ npm install
+fi
+
+./build.js
diff --git a/book/package.json b/book/package.json
new file mode 100644
index 00000000..9be40180
--- /dev/null
+++ b/book/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "cxx-book-build",
+ "version": "0.0.0",
+ "main": "build.js",
+ "dependencies": {
+ "cheerio": "^1.0.0-rc.3"
+ },
+ "prettier": {
+ "singleQuote": true
+ }
+}