Skip to content
Lee-WPublic
forked from arulrajnet/attila
 
 

Repository files navigation

Attila Pelican Theme

A content-focused responsive Pelican theme.

attila screenshot

Attribution

This project is based on the original work by arulrajnet.

Original repository:
https://github.com/arulrajnet/attila

This repository is a maintained fork that includes additional features, fixes, and packaging improvements.

The bundled icon sprite contains selected Font Awesome Free 6.7.2 icons and is distributed under its included license at static/icons/LICENSE.txt.

Overview

A content-focused responsive theme for Pelican.

It is ported from the ghost theme:
https://github.com/zutrinken/attila

Features

  • Responsive layout
  • Navigation support
  • Parallax cover images for posts, author archives, and blog (respects prefers-reduced-motion)
  • Author information for posts and author archives
  • Featured posts (via neighbors plugin)
  • Series posts (via series plugin)
  • Reading progress for posts
  • Automatic code syntax highlighting at build time via Pygments (light/dark adaptive, no client-side JS)
  • utterances comments support
  • Google Analytics, GAUGES, Piwik
  • Sharing buttons
  • Open Graph
  • Rich Snippets (JSON-LD)
  • Article subtitle
  • Writing heatmap (via heatmap plugin)
  • OpenStreetMap (via osm plugin)
  • umami support
  • Full-text search via Pagefind (Ctrl/Cmd+K)
  • CJK-aware reading time and word count (pelican.themes.attila.readtime)
  • Print stylesheet — hides site chrome, prints external link URLs
  • Lazy loading for images
  • Self-hosted web fonts (Libre Baskerville + Fira Sans) — no third-party font CDN, no tracking
  • Local SVG icon sprite — no render-blocking icon CDN
  • SRI (Subresource Integrity) on third-party CSS/JS bundles (Leaflet, MathJax)
  • No jQuery dependency — pure vanilla JavaScript

Install

Using pip

pip install git+https://github.com/Lee-W/attila.git@main

Then in your pelicanconf.py:

from pelican.themes import attila

THEME = attila.get_path()

Using pelican-themes

pelican-themes -U attila
  • List installed themes:
pelican-themes -l
  • Use that theme name in your pelicanconf.py

Article Subtitle

To set an article subtitle, set subtitle metadata in the front-matter.

:title: Page With Cover Images
:subtitle: article subtitle
:date: 2018-04-29 00:45
:author: arul
:category: foo
:tags: footag
:slug: page-with-cover-images
:cover: assets/images/page_cover.jpg

Header Covers

You can set cover images for blog, article, page, tag, category, and author.

Blog Cover

HOME_COVER is the site-wide cover image. It is the banner of your main index.html and the fallback cover for every page that has no cover of its own (articles, pages, tags, categories, authors and the other listings). For articles and pages it also feeds og:image. To set it, set the property HOME_COVER in pelicanconf.py:

HOME_COVER = "/assets/images/blog_cover.png"

Cover precedence, highest first:

Page Order
Article own cover, og_image, own color, HEADER_COVER, HOME_COVER, HEADER_COLOR
Page own cover, og_image, own color, HEADER_COVER, HOME_COVER, HEADER_COLOR
Tag, category, author own cover, HEADER_COVER, HOME_COVER; then own color, HEADER_COLOR, HOME_COLOR
Index and other listings HEADER_COVER, HOME_COVER; then HEADER_COLOR, HOME_COLOR

A color only shows when no cover image wins.

NOTE
HEADER_COVER property is deprecated. Use HOME_COVER and article-level covers instead.

Article Cover

To set a different cover image for an article, set cover metadata in the front-matter.

:title: With Cover Images
:date: 2018-04-29 00:45
:author: arul
:category: foo
:tags: footag
:slug: with-cover-images
:cover: /assets/images/article_cover.jpg

Page Cover

To set a different cover image for a page, set cover metadata in the front-matter.

:title: Page With Cover Images
:date: 2018-04-29 00:45
:author: arul
:category: foo
:tags: footag
:slug: page-with-cover-images
:cover: assets/images/page_cover.jpg

Tag Cover

To set a cover image for a tag, set the property TAG_META in pelicanconf.py

TAG_META = {
    "food": {
        "cover": "/images/food.png",
        "description": "Examples ipsum dolor sit amet. Topping",
    },
    "drinks": {
        "cover": "/images/orange-juice.png",
        "description": "Examples ipsum dolor sit amet. Juice",
    },
}

Category Cover

To set a cover image for a category, set the property CATEGORY_META in pelicanconf.py

CATEGORY_META = {
    "food": {
        "cover": "/images/junkie-stuff.png",
        "description": "Examples ipsum dolor sit amet. Topping",
    }
}

Author Cover

To set a cover image for an author, set the property AUTHOR_META in pelicanconf.py:

AUTHOR_META = {"zutrinken": {"cover": "/assets/images/zutrinken-cover.png"}}

Header Color

To define a simple header background color, set the property HOME_COLOR in pelicanconf.py

HOME_COLOR = "black"

You can use any valid CSS color. It is the fallback color of the main index and of every listing (tags, categories, authors, archives) when there is no cover image and no more specific color (HEADER_COLOR, or the tag/category/author's own color). Articles and pages do not use HOME_COLOR; they take their own color or HEADER_COLOR. See the precedence table in Blog Cover.

NOTE
HEADER_COLOR is deprecated. Use HOME_COLOR and article-level colors instead.

Social URLs

To use GitHub, Twitter, and Facebook URLs set these properties:

SOCIAL = (
    ("twitter", "https://twitter.com/myprofile"),
    ("github", "https://github.com/myprofile"),
    ("facebook", "https://facebook.com/myprofile"),
    ("flickr", "https://www.flickr.com/myprofile/"),
    ("envelope", "mailto:[email protected]"),
)

External Feed URL

Specify external feed (FeedBurner, etc.) using rss, rss-square, or feed icons in SOCIAL. A <link> will be placed in <head>.

Feed Links

<head> gets a <link rel="alternate"> for every feed Pelican writes (FEED_ALL_ATOM, FEED_ATOM, their RSS twins, and the category / tag / author feed of the current page). Two optional settings adjust them:

  • FEED_LINK_TITLES maps a feed setting name to the link title. The keys are FEED_ALL_ATOM, FEED_ALL_RSS, FEED_ATOM, FEED_RSS, and CATEGORY_FEED_ATOM, CATEGORY_FEED_RSS, TAG_FEED_ATOM, TAG_FEED_RSS, AUTHOR_FEED_ATOM, AUTHOR_FEED_RSS. Category, tag and author titles can use {name} (category names go through CATEGORY_TRANSLATIONS); it is the only placeholder, other braces are printed as they are. Feeds without an entry keep the default title (<SITENAME> Full ATOM Feed, <SITENAME> Category Atom Feed, ...).
  • FEED_EXTRA_LINKS adds links for feeds the theme does not know about, as (title, href) or (title, href, "rss") tuples (default type: Atom). href is escaped for HTML but otherwise used as given, so give a full URL; any type other than "rss" is Atom. They are listed after the site feeds. Setting either option to None is the same as not setting it.
FEED_ATOM = "en/feeds/all.atom.xml"
CATEGORY_FEED_ATOM = "en/feeds/{slug}.atom.xml"
FEED_LINK_TITLES = {
    "FEED_ATOM": "My Blog — English",
    "CATEGORY_FEED_ATOM": "My Blog — English — {name}",
}
FEED_EXTRA_LINKS = (
    ("My Blog — All languages", "https://example.com/feeds/all.atom.xml"),
)

With neither setting, the links are the same as in earlier versions.

User-defined CSS

Define CSS_OVERRIDE in pelicanconf.py to insert a user-defined CSS file after the theme CSS. Example:

CSS_OVERRIDE = ["css/myblog.css"]

User-defined JS

JS_OVERRIDE = ["js/custom.js"]

Author Bio

AUTHOR_META = {
    "zutrinken": {
        "name": "Zutrinken",
        "cover": "https://attila.demo.arulraj.net/assets/images/avatar.png",
        "image": "https://attila.demo.arulraj.net/assets/images/avatar.png",
        "website": "http://blog.arulraj.net",
        "location": "Chennai",
        "bio": "This is the place for a small biography with max 200 characters.",
    }
}

Supported social profiles: Facebook, GitHub, LinkedIn, Twitter, and Instagram.

Analytics

  • Google Analytics: GOOGLE_ANALYTICS
  • Gauges: GAUGES
  • Piwik: PIWIK_URL + PIWIK_SITE_ID (optional PIWIK_SSL_URL, host used instead of PIWIK_URL when set, without scheme)
  • umami: UMAMI_WEBSITE_ID

Menu Items

The menu item comes from the pelican config MENUITEMS.

MENUITEMS = (
    ("Home", "/"),
    ("Tag", "/tag/getting-started/"),
    ("Author", "/author/pelican/"),
    ("Category", "/category/examples/"),
    ("Archives", "/2015/11/"),
    ("Plugins", "https://github.com/pelican-plugins"),
)

Article Metadata

  • color → customize header color
  • cover → customize article header cover
  • og_image → OpenGraph image (fallback: cover → HEADER_COVER → default)
  • twitter_image → Twitter card image (fallback: header_cover → HEADER_COVER → default)

All image paths are relative to the site root. Absolute URLs allowed.

Tag Cloud

  • Tags page renders as a cloud
  • Configure font steps:
TAG_CLOUD_STEPS = 5

Default: 5, max supported by theme: 10.
For more steps, use CSS_OVERRIDE.

Language Switcher

To show a language switcher in the navigation, set LANGUAGES (list of (code, url) pairs). The active language comes from DEFAULT_LANG, which the i18n_subsites plugin overrides per subsite:

LANGUAGES = [
    ("zh-tw", "/zh-tw/"),
    ("en", "/"),
]

By default the switcher displays the raw language code. Use LANGUAGE_NAMES to map codes to human-readable labels:

LANGUAGE_NAMES = {
    "zh-tw": "台灣漢語",
    "en": "English",
}

Creative Commons License

To display a Creative Commons license badge on articles, set CC_LICENSE in pelicanconf.py:

CC_LICENSE = {
    "slug": "by-nc-sa",  # CC license slug, e.g. "by", "by-nc", "by-nc-sa"
    "version": "4.0",  # license version
    "name": "CC BY-NC-SA",  # human-readable name shown in the link text
}

The slug is used to build the license URL (https://creativecommons.org/licenses/<slug>/<version>/) and to render the corresponding Font Awesome Creative Commons icons.

Comments Intro

To show an introductory paragraph above the comments section, set COMMENTS_INTRO in pelicanconf.py:

COMMENTS_INTRO = "Comments are moderated. Be kind."

Search

Full-text search is powered by Pagefind. Attila includes a Pelican post-build hook that creates the search bundle after Pelican finishes writing the site, so a separate Node.js build step is not required.

Install Pagefind's extended Python package (recommended for Chinese and Japanese content), then enable Attila's hook:

pip install 'pagefind[extended]>=1.5.2'
PLUGINS = [
    # ...your other plugins...
    "pelican.themes.attila.pagefind",
]
PAGEFIND_ENABLED = True

Users can open the generated search modal by clicking the search icon or pressing Ctrl+K / Cmd+K. Search is disabled by default so sites that do not install Pagefind never emit broken /pagefind/ asset links. Set PAGEFIND_VERBOSE = True to show Pagefind's detailed indexing output.

Reading Time

Attila ships a CJK-aware reading-time plugin. Unlike word-per-minute plugins that split on whitespace (and therefore count an entire Chinese article as a handful of words), it counts CJK characters and non-CJK words separately and converts each with its own reading speed:

PLUGINS = [
    # ...your other plugins...
    "pelican.themes.attila.readtime",
]

With the plugin enabled, the article page meta line shows the estimated reading time and the word count (CJK characters + non-CJK words). Speeds default to 300 CJK characters and 250 words per minute and can be tuned:

READTIME_CJK_CPM = 300  # CJK characters per minute
READTIME_WPM = 250  # non-CJK words per minute
SHOW_READTIME_IN_ARTICLE_SUMMARY = True  # also show it on post cards in listings

Articles rendered by the post_stats plugin keep working: its read_mins value is shown when Attila's plugin is not enabled.

For multilingual weekday and month names, give every language an explicit locale. Python's locale is process-global, so a bare format string can otherwise inherit the locale of the previously processed article (for example, rendering 日 instead of Sun in English):

DATE_FORMATS = {
    "en": ("en_US.UTF-8", "%a, %d %b %Y"),
    "zh-tw": ("zh_TW.UTF-8", "%Y/%m/%d(%a)"),
}

The configured locales must be installed on the build host.

Responsive Cover Images

Cover images always emit a sizes attribute. For manually generated derivatives, provide a srcset globally or per article/page:

COVER_IMAGE_SRCSET = "/images/cover-640.jpg 640w, /images/cover-1280.jpg 1280w"
COVER_IMAGE_SIZES = "100vw"
COVER_IMAGE_WIDTH = 1280
COVER_IMAGE_HEIGHT = 720

Article and page metadata may override these with cover_srcset, cover_width, and cover_height. When using pelican-image-process, keep the existing large-photo responsive-image transformation; Attila supplies the image-process-large-photo class and preserves the generated srcset.

Fonts

The theme ships self-hosted web fonts — Libre Baskerville (body) and Fira Sans (headings/UI) — bundled as woff2 under static/font/ and declared via @font-face in style.css. Nothing is fetched from a third-party font CDN, so there are no extra DNS lookups and no requests leaking to Google. To use different fonts, override the font-family declarations via CSS_OVERRIDE.

Site Settings

Theme-specific settings that are all optional:

Setting Type Default Purpose
SITE_DESCRIPTION str unset Fallback <meta name="description"> / Open Graph description when an article or page has no summary
SITE_LOGO str (URL) unset Image shown in the navigation bar in place of the site name
SITE_VARIANT str "blog" Added to <body> as the class site-<variant>, for per-site CSS
COPYRIGHT_YEAR int / str 2026 Year shown in the footer copyright line
OG_LOCALE str "en_US" Default Open Graph locale
FAVICON str (path) unset <link rel="icon">, relative to SITEURL
FAVICON_IE str (path) unset <link rel="shortcut icon">, relative to SITEURL
TOUCHICON str (path) unset <link rel="apple-touch-icon">, relative to SITEURL
MANIFEST str (path) unset <link rel="manifest">, relative to SITEURL
POST_SHARE_MASTODON_DOMAIN str unset Mastodon instance domain; enables the Mastodon share button (https://<domain>/share)
RANDOM_ARTICLE_BUTTON bool False Show the "Read a random article" button on articles
RANDOM_ARTICLE_SAVE_AS str "random/index.html" Output path of the random-article page the button links to
SERIES_LIST_URL str "series/" URL of the series list page, used to mark the navigation item active
SERIES_LIST_SAVE_AS str unset Output path of the series list page; takes precedence over SERIES_LIST_URL when set
UTTERANCES_THEME str "github-light" utterances theme
SITE_DESCRIPTION = "Notes on Python and Pelican"
SITE_LOGO = "/images/logo.png"
FAVICON = "favicon.ico"
RANDOM_ARTICLE_BUTTON = True
POST_SHARE_MASTODON_DOMAIN = "mastodon.social"

Other Configuration

FACEBOOK_ADMINS = ["12345"]
GOOGLE_SITE_VERIFICATION = "token"
SHOW_AUTHOR_BIO_IN_ARTICLE = True
SHOW_CATEGORIES_ON_MENU = True
SHOW_CREDITS = True
SHOW_FULL_ARTICLE_IN_SUMMARY = False
SHOW_PAGES_ON_MENU = True
SHOW_SITESUBTITLE_IN_HTML_TITLE = True
SHOW_TAGS_IN_ARTICLE_SUMMARY = True

UTTERANCES_REPO = "Lee-W/attila"
# label on GitHub issue
UTTERANCES_LABEL = "blog-comment"

Comments are rendered with utterances only when UTTERANCES_REPO is set.

Contributing

Always open an issue before sending a PR. Discuss the problem/feature first.
If it's a good improvement, submit your PR. Otherwise, fork Attila and build your own theme.

Development setup

Requires uv, Node.js (the test suite runs node for the JavaScript tests and the icon sprite build) and gettext (msgfmt, for uv run poe build-i18n).

uv sync --group dev
uv run poe test      # run the test suite
uv run poe lint      # ruff check
uv run poe all       # format, lint, check commits, test

Local preview

Build the demo site in tests/ with the theme from src/, then serve the output:

cd tests
uv run pelican content -s default_conf.py -t ../src/pelican/themes/attila -o output
uv run python -m http.server 8000 --directory output

Open http://localhost:8000. tests/output is git-ignored.

CSS

static/css/style.css is generated — edit the modules in css-src/ and run uv run poe build-css to regenerate it. A test (tests/test_css_build.py) fails if the two ever drift apart.

Copyright & License

Copyright (c) 2015-2016 Peter Amende — MIT License
Fork and updates (c) 2016- Arulraj V — MIT License
Fork and updates (c) 2026- Wei Lee — MIT License

Some background images used from: https://github.com/gilsondev/pelican-clean-blog

Releases

Packages

Contributors

Languages