Build rapid and lightweight static websites with Hyde - IBM
Build rapid and lightweight static websites with Hyde - IBM
Build rapid and lightweight static websites with Hyde - IBM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
developerWorks® ibm.com/developerWorks/<br />
translated to paths for the web server, <strong>and</strong> provides basic metadata for some key<br />
pages.<br />
Templates <strong>and</strong> Jinja2<br />
Most <strong>websites</strong> these days can benefit from some degree of templating. A template<br />
system can help you separate common elements of your site's structure <strong>and</strong> pages<br />
from each page's individual content. For example, if you look at a weblog, sometimes<br />
more than half of the HTML of each page is boilerplate replicated across all entries.<br />
A template allows you to express that 50 percent of content only once <strong>and</strong> have it<br />
automatically applied to all the pages. A template system can also support smart<br />
features such as automatically generating a calendar of a weblog's archives.<br />
<strong>Hyde</strong> uses a similar template language to that of the popular Django framework,<br />
implemented through the Jinja2 project. Each template looks like HTML <strong>with</strong> some<br />
additional, special syntax for the template comm<strong>and</strong>s, as explored further below.<br />
The templates go in the layout directory, <strong>and</strong> you add <strong>and</strong> update templates there to<br />
manipulate the overall content outline of your site.<br />
Your content<br />
Most important of all is your own site's content, which you maintain in the directory<br />
of that name. You would generally have one file for each unique web page. Each<br />
content file starts <strong>with</strong> the page metadata <strong>and</strong> then has the HTML <strong>and</strong> template code<br />
for the page. This directory is also where you find <strong>static</strong> files to support the site, such<br />
as images, stylesheets, <strong>and</strong> script files.<br />
A small example<br />
A quick way to start <strong>with</strong> a nice-looking website is to download one of the many<br />
free web designs that include HTML, CSS, <strong>and</strong> even scripts as needed for a site's<br />
presentation. You can then replace the design's boilerplate <strong>with</strong> your own content <strong>and</strong><br />
tweak the look <strong>and</strong> feel. This is a straightforward process <strong>with</strong> <strong>Hyde</strong>, <strong>and</strong> you needn't<br />
restrict yourself to a web design for that specific software. In this section, I chose a<br />
regular, free HTML5/CSS3 template <strong>and</strong> adapt it for <strong>Hyde</strong>. It's called "Minimalism,"<br />
by Marija Zaric (see Resources), <strong>and</strong> is available under the Creative Commons<br />
Attribution (by) 3.0, so you can use it freely, even in commercial projects, as long<br />
as you credit the author for use of the template. Your <strong>websites</strong> using the template<br />
become derivative works of the template.<br />
I downloaded the template package <strong>and</strong> unzipped it. It contains an index.html file.<br />
The <strong>Hyde</strong> folder's content directory also contains a file by the same name, but it's<br />
not actually HTML but a Jinja2 template based on base.j2. What I did was turn the<br />
Minimalism file into a new template, by copying it as minimalism.j2. At the same time<br />
I copied the other, support files for the template to the appropriate locations:<br />
cp minimalism/index.html<br />
$PATH_TO_DIRECTORY/layout/minimalism.j2 cp minimalism/css/styles.css<br />
$PATH_TO_DIRECTORY/content/media/css/ cp minimalism/images/*<br />
$PATH_TO_DIRECTORY/content/media/images/<br />
<strong>Build</strong> <strong>rapid</strong> <strong>and</strong> <strong>lightweight</strong> <strong>static</strong> <strong>websites</strong> <strong>with</strong> <strong>Hyde</strong> Page 4 of 9