Rendez-vous sur Arrakis C'est lorsque nous croyons savoir quelque chose qu'il faut justement réfléchir un peu plus profondément. F. Herbert

swx - static site generator

This page in french

swx is a tool to generate a static website from a file tree written in markdown. Notice that any other makup language coul be used to generate html, such as txt2tags or pandoc.

Inspired by sw, swx will generate you html pages, create links between them in a menu. You cas use simple css and templates that will be included in your pages.

 Features

Example : source tree

/home/user/site/
    |style.css
    |--------------directory/
    |-----------------------index.md
    |-----------------------file1.md
    |-----------------------image.jpg
    |--------------directory2/
    |-----------------------index.t2t
    |-----------------------article.md

will become in output

/home/user/site.static/
    |style.css
    |--------------directory/
    |-----------------------index.html
    |-----------------------file1.html
    |-----------------------image.jpg
    |--------------directory2/
    |-----------------------index.html
    |-----------------------article.html

Install

Uncompress this archive : swx.tar.gz or download files here here

Install rsync and markdown (or any other converter of your choice)

Using

Simple run :

./swx repertoire_contenant_le_site

then, push you site the way you prefer with mercurial, git, rsync or even ftp

Configuration

To configure, edit swx.conf

You can change uppercase variables to fit your needs

Modyfi how your site looks with style.css

 Example

mkdir dossier
cd dossier
wget http://yeuxdelibad.net/coolrepo/swx.tar.gz
tar -xvf swx.tar.gz
mkdir monsite
vim monsite/index.md
vim monsite/page1.md
mkdir monsite/dossier1
vim monsite/dossier1/index.md

./swx monsite >> NEWS.swx

Appears monsite.static containing every pages converted to html and a new file NEWS.swx containing the list of news pages (used later)

 RSS feed

Use swx_rss.sh to generate feed.xml

./swx_rss.sh NEWS.swx "HOSTNAME" SOURCEDIR > DESTDIR/feed.xml

Replace :

 News list

Edit the script swx_news.sh to have a config you need :

Then, use the script

    ./swx_news.sh NEWS.swx DESTDIR/Articles/index.html SOURCEDIR

Replace :

 Site map

Generate a list of pages in your site with

    ./swx_plan.sh DESTDIR > DESTDIR/Divers/map.html

And replace of course : - SOURCEDIR - DESTDIR

 Sitemap generator

    ./swx_sitemap.sh DESTDIR http://yoursite.com > DESTDIR/sitemap.xml

Then, you can compress it :

    gzip --best -c DESTDIR/sitemap.xml > DESTDIR/sitemap.gz

Don’t forget to edit robots.txt

User-agent: *
Disallow:
Sitemap: http://votredomaine.net/sitemap.gz

Makefile

Example Makefile to edit to fit your needs:

DESTDIR=/home/xavier/site/epicededune/Rendez-vous_sur_Arrakis.static/
SOURCEDIR=/home/xavier/site/epicededune/Rendez-vous_sur_Arrakis/
HOSTNAME="http://yeuxdelibad.net"
NEWSPAGE=$(SOURCEDIR)/Articles/index.md

all:
    touch $(NEWSPAGE)
    ./swx Rendez-vous_sur_Arrakis >> NEWS.swx
    sed -i -e 's,Articles/.*index.md,,g' NEWS.swx
    ./swx_sitemap.sh $(DESTDIR) $(HOSTNAME) > $(DESTDIR)sitemap.xml
    gzip --best -c $(DESTDIR)/sitemap.xml > $(DESTDIR)/sitemap.gz
    ./swx_news.sh NEWS.swx $(DESTDIR)/Articles/index.html $(SOURCEDIR)
    ./swx_rss.sh NEWS.swx "$(HOSTNAME)" $(SOURCEDIR) > $(DESTDIR)/feed.xml
    ./swx_plan.sh $(DESTDIR) > $(DESTDIR)/Divers/Plan_du_site.html
clean:
    rm -rf *.static
menu:
    find foo -name "*.$(EXT)" -exec touch {} \;
    touch $(NEWSPAGE)
    ./swx foo
    ./swx_news.sh NEWS.swx $(DESTDIR)/index.html $(SOURCEDIR)
force:
    find Rendez-vous_sur_Arrakis -exec touch {} \;
    make all
serve:
    cd $(DESTDIR) && python3 -m http.server && x-www-browser http://localhost:8000

Then, just run :

The end

Most of script can be improved, and simplified.

Avoid weird file names (use detox!)

Do not hesitate to contact me for any suggestion here