Package: bsw
bswbsw - Build Static Website, a simple static website generator.Usage (the short version)usage: bsw_run.py [-h] [-C] [-s] [--init [PATH]] [--template TEMPLATE]

bsw - build static website

optional arguments:
  -h, --help           show this help message and exit
  -C, --clean          remove existing build folder before building
  -s, --serve          serve content after build (default port 8000)
  --init [PATH]        initialise a new bsw site as the specified path
  --template TEMPLATE  built-in template to use with --initNice and simple.Getting Startedbsw works on the current directory, and expects a couple of folders to
exist:pagestemplatesTo get started, we’ll need to create these folders and add a base
template (the primary site template) to thetemplatesfolder.$ bsw --init mynewsite
$ cd mynewsite
$ bsw --serveOpen <a href=”http://localhost:8000/about”>http://localhost:8000/about</a>
in your browser and you’ll see your new site, ready to go.bsw will read all the *.html and *.htm files inside thepagesdirectory
(recursively) and render them using the templates in the templates folder
(using base.html by default if a page doesn’t have a template directive).
The rendered pages will then be saved to thebuildfolder (which will be
created if needed).Variables in page (e.g.<!--page_title = "my page title"-->) are placed
into the templates at the placeholders (e.g.$page_title). It’s easy to
add your own, and you can see a great example of this in the sample blog
template and blog post.The best way to learn the syntax is to take a look at the example pages
and templates. They’re purposefully very simple and should be easy to
pick up.Static contentbsw will copy any files instatic/andtemplates/static/to to
the combinedbuild/static/folder where they can easily be
referenced by your page or template content. For example, reference thetemplates/static/logo.pngfile on your template or page as so:<imgsrc="/static/logo.png">.Static folders are completely optional and both template and site
statics are accessed from the same combined folder.IncludesYou can include reusable pieces of markup by usingincludedirectives.You must place all includes intemplates/includes/.For example, let’s create an include with a link to the bsw project
repository on GitHub:$ mkdir templates/includes
$ echo <<EOF > templates/include/github_links.html
> <p>
> <a href="https://github.com/davb5/bsw">github.com/davb5/bsw</a>
> </p>
> EOFWe can now reference this include from any of our page or template files
by adding the following directive to the page markup:<!-- include("github_links.html") -->FAQWhy are there two static folders?bswlooks for two static folders:static/templates/static/This allows you to keep your template static files separate from your
page static files, making it easier to reuse your template on other
sites.However, the use of either (or both) static folders is completely
optional.How do I create a template?Templates are extemely simple. The default template for any page which
doesn’t explicitly specify a template istemplates/base.html.It requires only a single tag:$page_contentThe content from each .html or .htm file inpages/is inserted into
the base template at the$page_contenttag.Pages can also pass values to the template, for example, you template
could contain the following:<head>
    <title>My Example Blog | $page_title</title>
</head>You can populate the$page_titlevariable for any page by declaring
it in a comment in the page markup, as follows:<!-- page_title = "My first blog post! -->The only template tag which is required is the ``$page_content`` tag.How do I use multiple templates?Additional templates can be created in thetemplatesfolder and
referenced from pages by using the specialtemplatepage variable as
so:<!--template = "my_special_case_template.html"-->The<!--template ...-->variable can appear anywhere in the page
content (it doesn’t need to be placed at the top of the file).Any page which doesn’t explicitly specify a template will use thebase
templatetemplates/base.html.How do I deploy my site?Your hosting environment will vary, but deployment is as simple as copying
the contents of the build folder to somewhere accessible on your web server.Popular workflows include using rsync (copying only files which have changes)
or git (handy if you already keep the site source content in a git repository).I updated my template or CSS but the change isn’t reflected in a new build. Why?By default, bsw won’t overwrite existing files in your build folder. This is to
avoid potentially longer build times on sites with lots of static content (for
example, large images or downloads). Try runningbsw--cleanor manually
delete the build file you’d like to regenerate.