aboutsummaryrefslogtreecommitdiffstats

bryanbrattlof.com

This is my static website's theme generated with Pelican.

Motivation

I spend most of my time working on backend things, which means I know absolutely nothing about html/css/js and the unwritten rules of how to combine them into an elegant website.

So I built this to learn.

Installing

The easiest way to install this theme is:

  1. cloning it into a folder in your project:
$ git clone https://gitlab.com/bryanbrattlof/bryanbrattlof.com theme
  1. installing the plugin dependencies:
  • pelican-webassets to compile and minify all of the SCSS assets into their respective CSS files.

all of which can be installed via pip(env):

$ pip install -r theme/requirements.txt
  1. and editing your pelican settings file, and putting the theme's path into the THEME setting.
THEME = 'path/to/theme'

Configuration

An example of the configuration changes needed to build this theme are located in the democonf.py.

These are their descriptions...

PLUGINS

To activate the plugins needed to properly build this theme, you'll need to append the plugins into your PLUGINS setting.

PLUGINS = [
   # ...
   'pelican_webassets',
   # ...
]

DIRECT_TEMPLATES

This theme has some extra templates that need to be included:

DIRECT_TEMPLATES = [
    'index',     # root landing page
    'ubad',      # custom 404 page
    'sitemap',   # sitemap.xml
]

that will also need their URL and SAVE_AS settings:

# sitemap.xml
SITEMAP_URL = 'sitemap.xml'
SITEMAP_SAVE_AS = 'sitemap.xml'

# 404 page
UBAD_URL = '404/'
UBAD_SAVE_AS = UBAD_URL + 'index.html'

WEBASSETS_SOURCE_PATHS

Because the SCSS assets aren't located inside the THEME_STATIC_PATHS directory, we have to add the folder to the assets ourselves.

WEBASSETS_SOURCE_PATHS = ['stylesheets']

WEBASSETS_BUNDLES

To make things simpler (on me, not you) I've defined several webasset.Bundles to compile the SCSS assets into their minifed CSS output.

More information about these bundles is provided in the pelican-webassets README

WEBASSETS_BUNDLES = (
    (
        'articles_css', (
            'article.scss',
        ), {
            'output': 'css/article.css',
            'filters': [
                'libsass',
            ]
        }
    ), (
        'indexes_css', (
            'index.scss',
        ), {
            'output': 'css/index.css',
            'filters': [
                'libsass',
            ]
        }
    ), (
        '404_css', (
            'ubad.scss',
        ), {
            'output': 'css/404.css',
            'filters': [
                'libsass',
            ]
        }
    ),
)

WEBASSETS_CONFIG

webassets uses libsass to compile the SCSS files for us. However by default, libsass will not compress the files. Adding a line to WEBASSETS_CONFIG will allow libsass to minify the files as well as compile them.

WEBASSETS_CONFIG = (
    ('libsass_style', 'compressed'),
)

TWITTER_HANDLE

(optional) The twitter profile you wish to supply for the twitter:site in the Twitter cards.

TWITTER_HANDLE = '@bryanbrattlof'

LOGO_IMAGE

(optional) The image you wish to use as your signature at the bottom of every page's footer.

LOGO_IMAGE = 'static/img/logo.png'

LICENSE

(optional) The license in (name, url) form you wish to include in the footer of every page.

LICENSE = (
    'Creative Commons Attribution-NonCommercial 4.0 International License.',
    'https://creativecommons.org/licenses/by-nc/4.0',
)

Want to Help?

Please feel free to help. Issues, pull requests, even patches via email, all are warmly welcomed.

License: WTFPL