This small project shows a possible workflow for converting Markdown files (.md) to HTML files (.html) using pandoc (docs, installation).
The main goal of this project is to show some commonly used options when running pandoc and give an example of how creating a multi-page website with pandoc could work.
convert.sh: Shows the arguments that are used with pandoc, how parameters are passed to pandoc and how creating the website can be automated.styling.css: A normal css file.template.html: The template file that is mostly.htmlbut includes pandoc control elements (denoted by$) which will be replaced during conversion.source/index.md: A simple example page, showing how the body of a markdown file is translated by pandoc and how a header section can be used to add meta information.
Write the page layout once in html and css and then convert multiple .md files to .html.
- The original author of this repo built their website montebaur.tech with this original approach.
pandoc, need version >=2.13 to process citationsentr(optional), used for automatic conversion triggering during developmentpython3
You can now use make instead of calling scripts directly (requires Bash & GNU Make).
make build
Build the site (runsconvert.sh).make clean
Delete the generated_website/directory.make watch
Rebuild on changes (requiresentr).make serve
Start a quick HTTP server athttp://localhost:8000for preview.
Windows users: run these commands inside Git Bash or WSL, where Bash and Make are available. You may need to install GNU Make via Chocolatey (choco install make in an elevated PowerShell) and then re-open your shell.
convert.sh: Builds the website, i.e. converts from Markdown to HTML. Takes as an input a list of markdown files and creates a folder website/ for the converted files. It will also copy all of the media data and styling info to this folder. website/ is essentially the root of the website.
./convert.shIf this command ran successfully, there should be a new file called _website/index.html which you can open in your browser.
autoupdate.sh: Watches changes in the markdown files and updates the website after a change occurs. This file is used for development and will update the website once a file was updated. Using the commands from the script to only watch a single file is recommended to safe time.
# Website will automatcially be regenerated if one of those files changes:
./autoupdate.sh source/projects/page1.md source/page_index.mdThis project is a further development of the approach in montioo/pandoc-md2html-example and builds upon it.