Skip to main content

SWG - A static website generator

Project description

Copyleft by Simone Margaritelli <>

What is SWG ?

SWG is a new generation static website generator, featured by the Mako ( template system, born from the need to have both performances and “WEB 2.0” contents and capabilities.

Given a set of files, one for each page/article, one for each author and one for the categories hyerarchy, SWG will read the configuration file you specify from command line and generate a complete static website, with tags and categories indexing.


To get the latest released version:

pip install swg

Create a new website

To start a new website, type:

swg --create website-folder-name

An example site with a basic structure will be created inside the ‘website-folder-name’ directory. Then you can type:

cd website-folder-name
swg --serve

To test the website locally. The first article is about customization and basic configuration, so read it carefully.

Generate your website

Once you are in the directory containing your website definition (with a swg.cfg file in it), just run:

swg --generate

To start website generation, other options are available, use

swg --help

To a display the complete list.

Importing from another platform

Right now, there’s the swg-wordpress script you can use to convert a WordPress XML backup file to the SWG format, to use it consider the following:

swg-wordpress --help
- SWG Wordpress Backup Importer -

Usage: swg-wordpress -i wordpress-backup.xml -u '' <options>

  -h, --help            show this help message and exit
                        The Wordpress XML backup file.
                        URL of the destination website.
  -o OUTDIR, --output=OUTDIR
                        Output directory, default is the current working
  -e FILEEXT, --extension=FILEEXT
                        Output file extension, default is txt.
  -I IMGDIR, --images=IMGDIR
                        If specified, it's the path where the importer will
                        try to download images referenced by articles.

So let’s say for instance, that you have your wp.xml file and you want to export it to the ‘’ directory, downloading images referenced by the articles into the ‘’ directory (the import will replace properly image urls), you will use the command line:

swg-wordpress -i wp.xml -u -o '' -I ''

And it’s all done! Now you just have to create the templates, fix the categories hyerarchy inside the file ‘’, customize your own description inside ‘’ and make the configuration file following the example below.

An example configuration file

# DB files extension
dbitem_ext = txt
# URL of the site you are going to generate
siteurl    =
# Site name / description
sitename   = An example site generated by SWG
# Site charset
charset    = utf-8
# Site language
language   = it
# Comma separated site keywords
keywords   = some, html, keywords, here
# Site destination basepath
basepath   =
# Site page files output extension
page_ext   = html
# Generated site output path
outputpath = out
# Items (dirs or files) to copy from datapath to outputpath (eg. static files, css, etc)
copypaths  = css, images, .htaccess
# Command to execute once the generation is finished, for instance an rsync :)
transfer   = rsync -ravz out/* -e ssh
# Enable or disable the pager on categories, index, tags and author pages
pager      = true
# If pager is enabled, this is the maximum number of items per page
items_per_page = 10
# Compress pages (ie. index.html.gz) and create (or update) .htaccess file to serve them as html files
gzip       = true
# Compression level, 0 to 9
compression = 9
# Clean output html with TIDY
tidyfy = true

Pretty self explanatory isn’t it ? :)

Testing your website locally

From version 1.2.4, SWG offers the possibility to test your website locally, once you are in the directory containing your website definition (with a swg.cfg file in it), run the following command:

swg --serve

This will start the website generation and a test webserver on http://localhost:8080/ .

Example project

For an example site, look at my personal blog github repo located here

Enjoy ^^

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swg- (144.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page