Miril::Manual - Why and how to use Miril, the static content management sytem.


  • Miril is written in perl and uses the CGI::Application framework.

  • Miril stores your data in a backend (text files, a database, etc.) and publishes it to static pages. Unlike homegrown static publishing solutions (e.g. scripts using the Template Toolkit), Miril provides a nice user interface for editing content (web-based or via a command-line application).

  • Miril has been designed from the very start to be extremely easy to deploy. The main distribution has only pure-perl dependencies. Stable Miril versions will be available in a tarball with all dependencies bundled, so that installing on a typical shared host should be a no-brainer.

  • Miril has been designed with small to medium-sized websites in mind, i.e. websites with hundreds of pages as opposed to thousands of pages. If you have a typical small website such as a corporate website or a personal blog Miril may be a better deal for you than full-blown content management systems since it is faster to deploy, easier to manage, and generally has less administrative overhead both for the site administrator and for the users.

  • Miril has a user interface that has been deliberately kept extremely simple and uncluttered. The goal is for the end users of Miril (those in charge of managing content) to require little or no training to start using it. This means that some of the administrative tasks (such as user management and adding special types of pages) can only be performed by editing the configuration files and templates manually. For a similar reason, Miril also takes a very simplistic approach towards access management and does not provide roles or complex permissions. In fact, Miril has been designed to be used in teams where 1) users generally can trust each other and complicated access management is not necessary and 2) there is at least one tech-savvy user who can take care of the occasional administrative tasks.

  • Miril is extensible. You can choose between different storage backends (currently only a file-based backend is provided), different templating systems, etc.


Miril is run as a cgi script. This means that:

  • On a shared host, you can run Miril from your cgi-bin directory. It will run slower than in a mod_perl environment, but since Miril will be used only when managing content this should not be a problem.

  • Of course, if you have sufficient control over your environment and the load on Miril demands it, you can accelerate Miril by running it under FastCGI or mod_perl.

  • Because Miril ultimately produces static content only, you can run it from your local machine and then synchronize your local output directory with the web server. This way you can manage websites on servers that don't even have perl installed, or where installing Miril would be difficult.


Currently Miril is installable only from CPAN. Simply run install Miril from your favourite CPAN shell. The CPAN distribution comes with an example website you can build on to get started faster.


Create required files and folders

Miril requires that you have the following files and folders in place:

  ~/miril - Base Miril directory
  ~/miril/sites - Site configuration and data
  ~/miril/sites/some_site/cache - Directory where Miril caches stuff
  ~/miril/sites/some_site/data - Directory where Miril store data files
  ~/miril/sites/some_site/tmpl - Directory where you keep the templates for building your site
  ~/miril/sites/some_site/cfg/config.xml - Main configuration file
  ~/miril/sites/some_site/cfg/users.xml - Usernames and passwords
  ~/miril/sites/some_other_site - You can keep info about more than one site
  ~/miril/lib - If you downloaded Miril with bundled dependencies, they will be here

Of these, the two configuration files are the only ones that you need to create manually, and more information is provided below. All other stuff is written by Miril itself, but it does need the directories to exist first. You can just unpack the example site provided with the Miril distribution to get started faster.

Create a cgi script

Once you have installed Miril, create a cgi script named or miril.cgi with the following content:

  use strict;
  use warnings;
  use Miril;

  my $app = Miril->new( PARAMS => { 
      miril_dir => $path_to_base_miril_dir,
      site      => $name_of_website,

A single Miril installation can handle multiple websites. $path_to_base_miril_dir should point to the base Miril directory, for example ~/miril. $name_of_website is the name of the website that will be managed by this particlar Miril instance (e.g. some_site or some_other_site).

Create a configuration file

Make sure you create your configuration file in the location that you chose above. Currently only XML is supported for the configuration file format.

Basic configuration options

A minimal configuration file has the following content:



    <secret>Some secret line</secret>


The options are explained here:


This is the directory where files (e.g. images, pdf files, etc.) uploaded by Miril users will be stored. Miril must have read-write access to this directory. In a typical installation this directory will be somewhere below your server's document root.


This is the directory where Miril will place all the output files it produces. In a typical installation this directory will be somewhere below your server's document root.


This is the base URL of your website and Miril will use this string to prefix all URL's that it produces. If your website is located at, you would set http_root to to produce fully qualified URL's. If you want your website to have relative URL's, you need to leave this option empty. If your website is located at, you would set http_dir to for fully qualified URL's and to /mywebsite for relative URL's.


This option specifies the base URL for accessing the files managed by the files_path option above. It follows the same rules as http_root.


If you have specified a relative URL in http_dir above, use this option to provide the domain name of your website for cases where fully qualified URL's are needed, such as RSS feeds. Leave empty if you have set http_dir to a fully-qualified URL.


A random phrase used for security purposes when encrypting authentication data stored in cookies (required by CGI::Applciation::Plugin::Authentication::Cookie).


Which view module, or templating system, will be used to render your site. Default is HTML::Template, which will load Miril::View::HTML::Template. You can also set this to Text::Template, and additional templating systems may be added in the future.

Configuring content types

Next you may need to configure your content types. This is what a basic configuration looks like:




You will get these two content types by default if you have not specified your own content types in the configuration file.


The user-friendly name of the content type, as it would appear to the end user.


A unique alphanumeric string identifying the content type, used internally by Miril.


The location, relative to output_path, where Miril will write entries of this content type.


The template file Miril will use to create html pages of this content type.

Creating lists

Miril allows you to create special pages which combine data from multiple posts - e.g. a list of articles, a RSS feed, etc. This is how you configure lists:




A unique alphanumeric string identifying the list.


The template file Miril will use to create this list.


The location of the file, relative to output_path, where Miril will write this list. If this is a grouped or paged list (see group and page below) this parameter accepts a Text::Sprintf::Named string used to generate the location of the individual grouped or paged lists.

Parameters accepted for grouped lists

  • Lists grouped by date: date, year, month.

  • Lists grouped by month: year, month.

  • Lists grouped by year: year.

  • Lists grouped by topic: topic.

  • Lists grouped by type: type.

  • Lists grouped by author: author.

Parameters accepted for paged lists

  • page, specifies the current page number


Specifies a grouped list. A grouped list will split the posts it matches into groups and output individual files for each group. This is a powerful option that allows you for example to create archives by month or by year or create lists of posts by topic. The following values for the group option are accepted: date, month, year, topic, type, author. Group works in conjunction with a sprintf-like format in the location option to define the output paths for the individual list files to be produced.


Specifies a paged list. A paged list will split the posts it matches into smaller lists each containing the number of posts specified as an argument to the page option, and prodice an individual output file for each such list. It works in conjuntion with a sprintf-like format in the location option to define the output paths for the individual list files to be produced. Additionally, the list object passed to your template file has a pager attribute, containing a Data::Page object for the current page.


The match elemement is used to determine which posts are included in the list. The filtering criteria are:


Only return posts with this type id.


Only return posts with the specified author.


Only return posts with the specified topic id.


Only return the N most recent posts matching the above criteria.

Only published posts can be included in the list (i.e. posts whose status is published and not draft).

Specifying authors

Miril allows you to specify the author of each post. The list of authors is specified in the confuguration file as follows:


      <author>J. R. R. Tolkien</author>
      <author>J. K. Rowling</author>


Note that any registered user can specify any author name for any post, so this is used only to display post information in the published site rather than to control access. This is part of Miril's design philosophy (trusted team).

Specifying topics

Miril has basic support for topics, or categories. The list of topics is specified in the confuguration file as follows:


                        <name>Fuzzy Animals</name>


Each post can then be associated with one or more topics.

Create a users file

You need a file with information about users and passwords in order to run Miril. The file must be named usres.xml and be located in the directory specified by the cfg_path option in the main configuration file. Currently only XML is supported as the configuration file format. The structure is as follows:

      <name>J. R. R. Tolkien</name>
      <name>J. K. Rowling</name>

Passwords can be stored either in plain text, or encrypted (using the MD5 algorithm). When you create a new user, you initially specify their password in plain text and them tell them to log in with this password but change it immediately afterwards. When a password is changed using Miril's user interface, it will be stored encrypted in the above XML file. Similarly, if a user has forgotten their password, you can temporarily reset it manually to a plain-text password and ask them to change it again.

Miril is not accessible to unregistered users. All registered users have identical permissions and can edit and publish all types of content.

Create your output templates

Once the configuration and users files have been set up, you can run Miril and edit content. In order to publish content, however, you need to provide the templates which will be used to render your pages. The templates are located in the directory specified by the tmpl_path option in the configuration file, and must contain all the templates specified when configuring content types and lists, as well as any additional templates referenced by them (such as headers and footers). Currently the only supported template format is HTML::Template with HTML::Template::Plugin::Dot. The templates are initialised with the die_on_bad_params option set to false, and the global_vars option set to true.


Each template used to generate an individual post is passed a post paremeter, which is a Miril::Post object containing all information about the post being rendered. The structure of the post object is as follows:


The title of the post.

The alphanumerical id of the post.


The teaser of the post, rendered into html.


The full text of the post, rendered into html.


A Miril::Type object. Has four properties: id, name, location and template.


A Miril::URL object. Has three properties: abs - an absolute URL, rel - a relateive URL, and tag - a tag URI for Atom feeds.

The author of the post.


A Miril::DateTime object. Has three methods: epoch - returns epoch time, iso - returns time in an ISO-compliant format suitable for Atom feeds, and strftime - returns time formatted on the basis of the "strftime" in POSIX-compliant string passed as an argument.


A Miril::DateTime object. See above for details.


An arreyref of Miril::Topic objects associated with this post. Each topic is an object with two properties: id and name.


Each template used to generate a list is passed aa list paremeter, which is a Miril::List object with the following methods:

List id (as specified in the configuration file).


List title (as specified in the configuration file).


An array reference of Miril::Post objects contained in the list. See above for details.


A Miril::URL object representing the URL where the list will be visible when published.


The number of posts contained in the list.

A method that groups the posts in the current list according to the parameter passed, and returns a list of Miril::List objects representing the resulting lists. Accepted parameters are date, month, year, topic, type and author. If called without arguments, returns the parameter by which the current list has been grouped, and undef if the list was not generated as a result of grouping.


For lists that have been generated as a result of grouping, returns an object that can be used to identify the current group. For example, when a list has been grouped by topic, the key method of each of the resulting list objects will return a Miril::Topic object representing that list's topic. Similarly lists grouped by type are identified by a Miril::Type object, lists grouped by date, month or year are identified by a Miril::DateTime object, and lists grouped by author are identified by an author string.


A Miril::DateTime object representing the time of createion of the list. Useful for Atom feeds.


Returns an individual post from the list.


Once you have configured Miril, you can access it by typing the url of the cgi script you created, e.g. Miril's user interface has the following elements:


This is the main screen. It displays a list of all content entries. It provides links to search entries or to post a new entry.


Displays a list of all files the user has uploaded and a link to a file upload form.

Edit Post

This screen is displayed when creating a new post or when modifying an existing one. Most of the options should be self explanatory, but there are a few things to keep in mind:

  • The ID field is an aplphanumeric string which servers as an unique id for this post. Future versions may create this id automatically and hide it from the user altogether. It may be useful, however, to specify it manually, since this id is used to generate the url of the output file (usually by attacing .html at the end) and the user may want to have control over the url for SEO purposes.

  • The status field has two options - draft and published. Posts marked as draft will be available for viewing and editing from Miril's UI, but will not be published to the live website.

  • The post text is run through a filter before publishing. Currently only Markdown is available via the Text::MultiMarkdown module.

  • Additionally, you can break your post into a teaser and full text by inserting the <!-- BREAK --> string somewhere in the post text. The content before the break mark will be available in the teser property of the post object passed to your templates.

Other data passed to templates

In addition to the post and list objects respectively, each template file is passed the following arguments:


The string id of the respective post or list object


The title of the respective post or list object


The global Miril configuration object (i.e. the contents of the configuration file as a hashref).


  • There are no tests yet.

  • The code is messy and buggy - this is still an alpha release!

  • The API is going to be changing a lot before the 1.0 release, so be sure to keep up with the development process (see "SUPPORT" below) if you plann to use Miril at this stage. Things that may change include the structure of the configuration file, the structure of the post objects, and the API for extending Miril.



The Miril website will be located at

Bugs and feature requests

Please use the Github issue tracker at to report bugs and request features.

Mailing list

Support can be obtained via the Google Groups page:


Miril is hosted on Github at


Peter Shangov, <pshangov at>


Copyright 2009-2010 Peter Shangov.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 484:

Expected text after =item, not a bullet