pelicanconf.py - Paths and Meta Data

Paths

# paths
PATH = 'content'
PAGE_PATHS = ['pages']
BLOG_PATH = 'blog/'
ARTICLE_PATHS = [ BLOG_PATH ]
#output
OUTPUT_PATH = 'output/'
DELETE_OUTPUT_DIRECTORY = True

METADATA

#metadata
PATH_METADATA= '(?P<path_first_dir>([^/]*[/])?)(?P<path_no_ext>(.+/)?)(?P<path_filename_no_ext>[^/]*)\..*'
FILENAME_METADATA = r'(?P<sortprefix>([0-9][0-9][_])?)(?P<date>\d{4}-\d{2}-\d{2})[_](?P<slug>[a-zA-Z][a-zA-Z0-9_-]*)(\.(?P<lang>[a-z]{2,3}))?\Z'

path_first_dir cuts off the directory from PAGE_PATHS or ARTICLE_PATHS. Hence these are not allowed to contain "/". path_no_ext then serves to place the pages into the web root.

sortprefix cut off an optional sort prefix. date, slug and lang are all derived from the file names.

With these pieces the output paths and URLs are constructed:

#output paths and urls
PAGE_SAVE_AS= '{path_no_ext}{slug}.html'
PAGE_URL= '{path_no_ext}{slug}.html'
PAGE_LANG_URL = '{path_no_ext}{slug}.{lang}.html'
PAGE_LANG_SAVE_AS = '{path_no_ext}{slug}.{lang}.html'
# URLs (blogging)
ARTICLE_URL = BLOG_PATH + '{path_no_ext}{path_filename_no_ext}.html'
ARTICLE_SAVE_AS = BLOG_PATH + '{path_no_ext}{path_filename_no_ext}.html'
ARTICLE_LANG_URL = BLOG_PATH + '{path_no_ext}{path_filename_no_ext}.html'
ARTICLE_LANG_SAVE_AS = BLOG_PATH + '{path_no_ext}{path_filename_no_ext}.html'
INDEX_URL = BLOG_PATH + 'index.html'
INDEX_SAVE_AS = BLOG_PATH + 'index.html'
INDEX_LANG_URL = BLOG_PATH + 'index.{lang}.html'
INDEX_LANG_SAVE_AS = BLOG_PATH + 'index.{lang}.html'
CATEGORY_URL = BLOG_PATH + 'category/{slug}.html'
CATEGORY_SAVE_AS = BLOG_PATH + 'category/{slug}.html'
CATEGORIES_SAVE_AS = BLOG_PATH + 'categories.html'

Copyright © 2016 Uwe Ritzmann - Created with Pelican, Python and Skeleton.