Skip to navigation

How does Pyplate store content?

Pyplate's content directory contains a directory structure that mirrors the site's category structure. Every time a category is created, a corresponding directory is created in the content directory tree, and in the web root directory.

Posts are stored as HTML files in the appropriate dirctory in the content directory tree. These files only contain the HTML code for each post, without any of the code for the rest of the page. When a page is served dynamically, Pyplate builds a page and embeds the contents of one or more post files in the page.

When a page is requested by a user, the domain name is stripped from the requested URL, leaving a relative path. For example, a request for a page at gives a relative path of /foo/bar/bletch.html. Pyplate uses the relative path and translates it to an absolute path by appending it to /usr/share/pyplate/content. The file containing the post can be found at /usr/share/pyplate/content/foo/bar/bletch.html.

The Web Root Directory

When Pyplate is installed, Apache's default web root directory, /var/www, is moved to /var/www2. In it's place, the Pyplate installation script creates a file system link from /var/www to /usr/share/pyplate/webroot. Files and directories in Pyplate's webroot directory can be accessed via /var/www.

Cached Pages

Dynamically generating every page, every time it is served, puts an unnecessary load on the CPU. It's better to generate pages in advance and cache them as static HTML files. Cached pages are stored in the web server's root directory so that they can be served without the CMS executing. This significantly decreases page load time and increases the number of concurrent users that a web server can handle.

The site's category structure is also mirrored in the web root directory. When a page is cached, an HTML file is created in the appropriate place in the web root directory. When a page at is cached, the complete page will be stored in /var/www/foo/bar/bletch.html.

Clearing the Cache

when you add pages or make changes to your site, you must clear the cache and rebuild it. Cached pages aren't automatically updated when you make changes to your site, so if you to modify a page that's been cached, you need to go to the admin area and click on the "Clear Cache" button. When you've finished making changes to your site, click on the "Build Cache" button to rebuild the page cache.

Post pages and category pages

The example above shows how individual posts are stored, displayed and cached. As well as handling pages that contain individual posts, Pyplate also needs to handle pages that correspond to entire categories. Category pages display all the posts in one category in a single page. These pages correspond to a directory in Pyplate's content directory. To continue using the example above, if a user visits, Pyplate creates a page containing all the posts in /usr/share/pyplate/content/foo/bar/.

When a category page is cached, it is saved in the corresponding place in the web root directory in a file named dir.html. When the page at is cached, it will be stored in /var/www/foo/bar/dir.html. The web server must be configured to serve dir.html when users request a page that corresponds to a category.

Sidebar Caching

Generating the sidebar every time a page is served would be too time consuming, so the sidebar is cached automatically. The sidebar is cached independently of the rest of the site. Any time a page is requested, Pyplate will check to see if the sidebar has been saved in the template directory. If not, the sidebar will be generated and saved. The next time a page is requested, the sidebar will already exist, so the page load time and the load on the server will both be reduced.

The sidebar file is deleted when the page cache is emptied. It is also deleted when pages or categories are added, modified or deleted.

Uncategorized Pages

Some pages don't need to be displayed in a site's navigation system, such as pages with terms and conditions or a privacy policy. These kinds of pages can be omitted from site navigation by creating them in the 'General' category. This isn't a real category; it's a dummy category that tells Pyplate that a particular page doesn't need to be included in the category hierarchy. The posts for uncategorized pages are stored in /usr/share/pyplate/content.

Share this page:

Follow me