Blogofile is a website compiler, but instead of translating something like C++ source code into an executable program, Blogofile takes Mako templates, and other Blogofile features, and compiles HTML for viewing in a web browser. This chapter introduces the basic building blocks of a Blogofile directory containing such source code.
The best way to understand how Blogofile works is to look at an example. Create a new directory and inside it run:
blogofile init simple_blog
This command creates a very simple blog that you can use to learn how Blogofile works as well as to provide a clean base from which you can create your own Blogofile based website.
For a more complete example, you can checkout the code for the same website you’re reading right now, blogofile.com:
blogofile init blogofile.com
The rest of this document will assume that you’re using the simple_blog template. It is the defacto reference platform for Blogofile.
Inside the source directory are the following files (abbreviated):
|-- _config.py |-- _controllers | |-- blog | | |-- archives.py | | |-- categories.py | | |-- chronological.py | | |-- feed.py | | |-- __init__.py | | |-- permapage.py | | `-- post.py |-- _filters | |-- markdown_template.py | |-- syntax_highlight.py |-- index.html.mako |-- _posts | |-- 001 - post 1.markdown | |-- 002 - post 2.markdown `-- _templates |-- atom.mako |-- base.mako |-- chronological.mako |-- footer.mako |-- header.mako |-- head.mako |-- permapage.mako |-- post_excerpt.mako |-- post.mako |-- rss.mako `-- site.mako
The basic building blocks of a Blogofile site are:
- _config.py - Your main Blogofile configuration file. See Configuration File
- Templates - Templates dynamically create pages on your site. index.html.mako along with the entire _templates directory are examples. See Templates
- Posts - Your blog posts, contained in the _posts directory. See Posts
- Filters - contained in the _filters directory, filters can process textual data like syntax highlighters, translators, swear word censors etc. See Filters
- Controllers - contained in the _controllers directory, controllers create dynamic sections of your site, like blogs. See Controllers
Any file or directory not starting with an underscore, and not ending in ”.mako”, are considered regular files (eg. css/site.css and js/site.js). These files are copied directly to your compiled site.
Now that you have an example site initialized, we can compile the source to create a functioning website.
Run the following to compile the source in the current directory:
Blogofile should run without printing anything to the screen. If this is the case, you know that it ran successfully. Inside the _site directory you have now built a complete website based on the source code in the current directory. You can now upload the contents of the _site directory to your webserver or you can test it out in the embedded webserver included with Blogofile:
blogofile serve 8080
Go to http://localhost:8080 to see the site served from the embedded webserver. You can quit the server by pressing Control-C.
When the Blogofile build process is invoked, it follows this conceptual order of events:
Click for larger SVG view