Preface

This is one of the articles in a series about how I fine tuned my Pelican+Elegant web site to make it “more mine”. For other articles in the series, click on the title of the article under the heading “Fine Tuning Pelican” on the right side of the webpage.

Unlike my series on Choosing and Setting Up Pelican, these articles are intended to be byte sized, addressing specific fine tunings I made to my own website. As such, the first article in this series contains a Disclaimer section with generic information for each of the articles in the series.

Introduction

When creating content for a website, it is important to be able to create the content in a way that works for you, changing the configuration to suit your needs. For different reasons, when you publish that content, control of how that content is displayed is important to the character of your website. These settings control these aspects of the content publishing for the website. This article goes over some of the more useful settings for pages and articles and how they affect the website.

Where Is the Content Located?

I prefer to keep different forms of content in different locations, just to make it easier to keep where things are in my head. As such, I have separate content directories for each type of content:

ARTICLE_PATHS = ['articles']
PAGE_PATHS = ['pages']
STATIC_PATHS = ['images', 'theme/images', 'extra/robots.txt']

In my website’s content directory, I have 4 main directories: articles, pages, images, and extra. The first two are easy to explain, and I set the Pelican configuration values ARTICLE_PATHS and PAGE_PATHS to point to those directories.

The static paths specified by the Pelican configuration values for STATIC_PATHS are for folders containing anything that does not need transformation but is part of the website. The most important directories in that category are any images that either I provide or are provided by the theme. The robots.txt file will be covered in a future article, but provides guidance for any robots that are crawling the website.

As I intend to keep publishing to this blog for a long time, it was important to me to make sure that I have an organization that can scale with me. By keeping each type of content separate from each other, it allows me to find articles quickly. I take this a step further and create a directory for any series that I am writing, keeping both the draft articles and published articles in that directory. An advantage of this is it allows me to ensure a group of articles has a consistent look and feel within that group with little effort.

How is the Content Published?

For the publishing of website pages, there are very few options for controlling their location, as Pelican assumes that the collection of pages is pretty constant, while the collection of articles will change frequently.

As such, there are two main configuration values that control where the article is published. By default, both of these values are set to the same value {slug}.html, publishing all articles in the root output directory. That didn’t seem right to me, so I changed these values to the following:

ARTICLE_URL = '{date:%Y}/{date:%m}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = '{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'

When the article is published, it will be published to a directory mostly dictated by the publish date of the article, with the article itself written as an index.html file within that directory. For my tastes, this organizes the articles on the website in a manner in which I can quickly see what I published and when. The default values for ARTICLE_URL and ARTICLE_SAVE_AS just published everything in the root output directory, and that just seemed to cluttered for me.

How Many Articles To Show For Lists?

One of the other Pelican configuration values that I needed to set was the DEFAULT_PAGINATION value. On the main page, where the list of the most recent articles is displayed, I want to show a decent number of articles, but I don’t want them to fall off the bottom too much. As such, I set the following configuration value to provide a default pagination of 10 items:

DEFAULT_PAGINATION = 10

I am not sure if this is the right value to start with, but it seems like a decent place to start. I expect to make changes to this as I get more feedback from readers, so just giving it a decent starting value was enough.

What Was Accomplished

When writing content for a website, it is important to be able to create the content and display content in a manner that works for you, the content author. I described the settings that I have for my website which control where the content is stored as well as where the rendered content is published. In addition, I cover a configuration value that dictates the default for the maximum number of articles to show in a list.

Like this post? Share on: TwitterFacebookEmail

Comments

So what do you think? Did I miss something? Is any part unclear? Leave your comments below.


Published

Fine Tuning Pelican+Elegant

Category

Website

Tags

Stay in Touch