website Recipes

“How Do I…” for website powered sites

What is website?

Settings and Defaults

How can I set a default author for all posts?

In your _config.py add a dictionary DEFAULTS with the key AUTHOR:

DEFAULTS: {
    "AUTHOR": "John Doe"
}
How can I add new pseudo-protocols?

Pseudo-protocols allow you to abbreviate hyperlinks in your article posts. New ones are set in the _config.py file with the variable PROTOCOLS:

PROTOCOLS: {
    "foo": "http://example.com/%s"
}

You can then use it in your posts like this:

href="foo:bar"

which will turn out as

href="http://example.com/bar"
How do I enable comments for articles?

Since all articles are compiled to static HTML, website uses Disqus to host commenting functionality. Add your Disqus user name to _config.py, and the rest comes automatically:

DISQUS_NAME = "foobar"

Articles

How do I add meta-data or headers to articles?

The syntax of an article file is quite simple. First there come the headers in the form of key-value pairs, then an empty line followed by the post body (HTML). Header lines may be split by beginning following lines with a single white space. A complete post file looks like this:

Title: My Post
Author: John Doe
Date: 2011-07-01T12:00:00Z
Subject: website, writing, recipe

<p>This is a blog post.</p>
<p>There are lots of paragraphs</p>
<h2>Or Headings</h2>
How can I create categories for articles?

This is simple. Use folders under _article to organize your posts. For example, putting a file under _articles/my_cat/my_post.html gives the post the category “my_cat”. Nesting folders is of course supported.

How can I create tags for articles?

Use the header Subject and a comma-separated list to define tags for a post:

Title: My Post
Subject: Tag 1, Tag 2

<p>Post content goes here…</p>
How do I create a series of articles?

There are two headers, that are used for this. Requires points to another article, that preceeds the current, and isRequiredBy references the next, following part. If you give the article an ID, you can reference it easily:

Title: Part 2 of 3
ID: Part_2
Requires: Part_1
IsRequiredBy: Part_3

<p>This is part 2 of 3…</p>
How can I modify an article’s short description on index pages?

Usually index pages show the first 200 characters of the article. You can change this in two ways: If you add a header Abstract, this abstract is displayed per default before the article text, and is also used as description. If you specify the header Description, this is used as index page description, but doesn’t occur on the article’s page.

Title: My Post
Description: This appears on index pages
Abstract: This is displayed in front of the article and
 on index pages, if Description is not set

<p>This appears, if neither is set…</p>
Can specific articles have no comment form?

The Status header is used for this. Add the value no-discussion and the Disqus code will not be embedded:

Title: There’s nothing to discuss
Status: no-discussion
Can I prevent an article to appear in the index pages?

Add the value noref to the Status header:

Title: This should not appear on index pages
Status: noref
An article should not be indexed by search engines. How?

You can add a robots.txt to your project, that will automatically copied to the project:

User-agent: *
Disallow: /my-secret-post.html

Alternatively use the Robots header to set the corresponding meta element in the finished HTML page:

Title: Don’t spider me
Robots: no-follow, no-index
Can I use custom CSS and JS in my posts?

You can always embed Javascript in your post and it will be output straight through. For CSS it is a bit more complicated, because it should live in the HTML head. You can use the header Stylesheet to embed them. The strings #a# and #s# will be replaced by the absolute path to the article and to the static files, respectively.

Stylesheet: #a#article.css, #s#series.css

Newsfeeds and Sitemaps

Can I prevent an article to appear in the news feed?

Dynamic Content

How can I create a simple contact form?
How do I add comment functionality to my posts?
This is answered above.
How can I offer a site search?

Templates, Static Content and Custom Markup

I need XHTML 1.0 instead of HTML5. Where can I change the markup?
Can I use a completely different template for a single post?
Where do I put my global CSS and JS files?
How do I reference images from my static files in articles?

Translations and Languages

How do I translate the template strings?
I’m not satisfied with the default translation. Can I overwrite it?
How can I provided articles in several languages?