I write a Markdown document (e.g. How-I-build-this-website.md
) and add its
.html
counterpart to the $(pages)
macro of this Makefile
:
.SUFFIXES: .md .html
pages = \
index.html \
How-I-build-this-website.html
.md.html:
markdown $< > $*.tmp
cat header.html $*.tmp footer.html > $@ || (rm -f $@; false)
-rm -f $*.tmp
.PHONY: all
all: $(pages)
$(pages): header.html footer.html
.PHONY: clean
clean:
rm -f $(pages) *.tmp
Where header.html
is the following:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Stuff of matti</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<p><a href="index.html">Stuff of matti</a></p>
<hr>
And footer.html
is the following:
<hr>
<p><a href="#">Back to top ↑</a></p>
</body>
</html>
Then I run make
:
$ touch How-I-build-this-website.md
$ make
markdown How-I-build-this-website.md > How-I-build-this-website.tmp
cat header.html How-I-build-this-website.tmp footer.html > How-I-build-this-webs
ite.html || (rm -f How-I-build-this-website.html; false)
rm -f How-I-build-this-website.tmp
Links to new pages I add to index.md
manually.
Then I upload the changed files by hand.