# make(1) website
       
       make website with make, cut, sed, date, sh, openrsync, ssh ~ 71 LOC
       
 (BIN) make-website.tgz
       
       ## FR
       
       Voici une méthode pour créer un site web uniquement avec un Makefile et éventuellement un convertisseur markdown ou autre langage markup..
       
 (HTM) Makefile
       
       Le site consiste en une structure de dossiers/fichiers. Les pages web sont des fichiers markdown avec l'extension .md. Tout ceci réside dans un dossier portant le nom de domaine du site foo.tld.
       
       ### Fichiers
       
       Les fichiers ''head.tpl'' et ''foot.tpl'' contiennent le code html qui sera au début et à la fin de chaque page.
       
       ''foo.tld'' est la structure du site web avec des dossiers, des images et des fichiers markdown.
       
       Avec le fichier Makefile suivant, on peut convertir si besoin tous les fichiers markdown en page html dans le dossier foo.tld. L'outil lowdown est utilisé ici (MDTOHTML) en guise d'exemple. Ce fichier doit être édité pour convenir à vos besoins.
       
 (HTM) https://kristaps.bsd.lv/lowdown/
       
       ```
       .SUFFIXES: .md .html
       
       # markdown converter
       MDTOHTML = lowdown \
           -D html-skiphtml \
           -D html-head-ids \
           -E smarty \
           -d metadata \
           --html-no-skiphtml \
           --html-no-escapehtml
       SRCDIR = foo.tld
       SRC != find $(SRCDIR) -type f -name \*.md
       OUT = ${SRC:.md=.html}
       
       
       all: $(OUT) $(SRCDIR)/sitemap.xml $(SRCDIR)/all.html
       
       clean:
           find . -name \*.html -delete
       
       .md.html:
           @echo $<
           @cat head.tpl > $@
           @$(MDTOHTML) $< >> $@
           @cat foot.tpl  >> $@
           @bin/title.sh $@
       
       $(SRCDIR)/sitemap.xml: $(OUT)
           @echo sitemap
           @bin/sitemap.sh $(OUT) > $(SRCDIR)/sitemap.xml
           @gzip --best -c $(SRCDIR)/sitemap.xml > $(SRCDIR)/sitemap.gz
       
       $(SRCDIR)/all.html: $(OUT)
           @echo $@
           @cat head.tpl > $@
           @bin/sch.sh $(OUT) | $(MDTOHTML) >> $@
           @cat foot.tpl  >> $@
           @bin/title.sh $@
       
       serve:
           cd $(SRCDIR) && python3 -m http.server
       
       upload:
           openrsync -e "ssh" -av $(SRCDIR)/ user@foo.tld:/var/www/htdocs/foo.tld/
       ```
       
       * make : construit tout le site, mettant à jour les pages ayant été éditées depuis la dernière génération.
       * make clean : supprime toutes les pages ''*.html''
       * make serve : permet de voir son site web avec un serveur http local avant de l'uploader. Il faut ouvrir un navigateur à l'adresse http://localhost:8000.
       * make upload : uploade son site sur un serveur accessible en ssh.
       
       Le dossier bin contient des scripts permettant d'ajouter quelques fonctionnalités.
       
       * ''bin/title.sh'' permet de préciser le titre d'une page après qu'elle soit générée. Le titre est ajouté juste sous la balise .
       * ''bin/sitemap.sh'' crée un fichier ''sitemap.xml'' pour l'indexation.
       * ''bin/all.sh'' crée une page listant toutes les pages existant sur le site (pratique pour une recherche).
       
       Pour exclure certains fichiers de la liste, find dispose de toutes les options qu'il faut :
       
       ```
       SRC != find $(SRCDIR) -type f -name \*.txt -a \
           ! -name robots.txt -a \
           ! -name twtxt.txt
       ```
       
       ## EN
       
       Create a website only with make and a markdown converter.
       
 (HTM) https://man.openbsd.org/make
       
       The website is a file/directory structure containing .md files to convert and pictures and stuff. All of this is in a directory named foo.tld.
       
       ### Files
       
       ''head.tpl'' and ''foot.tpl'' are templates inserted before and after the content of each page generated from ''.md'' files.
       
       ''foo.tld'' is the website structure.
       
       Makefile should be edited to suit your needs. (change MDTOHTML if you want, default is using lowdown). It helps to :
       
       * make : build whole site
       * make clean : delete all *.html
       * make serve : check your website before upload. Open http://localhost:8000.
       * make upload : upload your website to a server using ssh and openrsync.
       
       bin directory contains scripts to add some features :
       
       * ''bin/title.sh'' set page title just after tag found. (at the next line)
       * ''bin/sitemap.sh'' creates sitemap.xml.
       * ''bin/all.sh'' creates a page listing all pages on website.
       
       ---
 (DIR) /