Convert a Google doc to a doc site

  • a full-text search box,
  • a sidebar for navigating around the Table of Contents, and
  • each chapter be put on its separate page.
# Replace this with the path to the file you downloaded.
FILE="The Project Gutenberg eBook of Alice’s Adventures in Wonderland, by Lewis Carroll.docx"
# Convert the docx file to epub:
pandoc -s "$FILE" -t epub --epub-chapter-level=2 -o all.epub
# epub is just a zipped version of a static website:
unzip -q "all.epub" -d . && rm "all.epub"
jekyll new EPUB --force
# Install a good theme:
echo 'gem "just-the-docs"' >> Gemfile
# Tell Jekyll to use this theme:
sed -i '' 's/^theme: minima/theme: "just-the-docs"/g' _config.yml
# Install the packages:
bundle install
for i in text/*.xhtml
pandoc -s ${i} -o ${i%.xhtml}.md
sed -i '' 's/^generator: pandoc/layout: default/g' text/*.md
# Remove bookmarks:
sed -i '' 's/{#.*}$//g' text/*.md
# Remove lines that starts with `:::`:
sed -i '' '/^:::/d' text/*.md
cd text
rg "^##" -m 1 *.md | while read line; do
file=${line%:## *}
title=${line#*:## }
# Replace the auto-generated title with the title found.
sed -i '' "s/^title: .*\xhtml$/title: ${title}/g" "$"
# (Optional) Rename the file:
mv "$file" "$"
cd ..



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Tech writer with creative analogies. Website: | Donate: