5

I rather like the default Pelican theme notmyidea. It serves my purposes nicely.

However, in order to implement the Python-Markdown admonishments extension, I need to add a few css rules to the template.

Nothing I can find in the documentation (or through googling) seems to explain how to do this. Only how to create a brand new theme, or use a custom style sheet, which overrides the default style sheet.

Is there a way to add a supplementary style sheet or even just a few supplementary rules?

mas
  • 1,155
  • 1
  • 11
  • 28
  • Will the rules be used for every page on your site or maybe just a few? – helb Jan 04 '19 at 21:25
  • I'd like for every page. The syntax `!!! \n` is a Markdown syntax for note boxes and warnings. It produces a `
    ` tag. I'd like to be able to use it in any post. It's just a blog. As lightweight as I can make it.
    – mas Jan 04 '19 at 21:33
  • Alternatively, if I can just find the directory containing the `notmyidea` theme already installed and modify the css files _there_, I'd be fine with that dirty hack. – mas Jan 04 '19 at 21:35
  • It's in the python packages directory (`site-packages/pelican/themes/notmyidea/`)… but that would break your changes when you update Pelican. – helb Jan 04 '19 at 21:40
  • Then that hack is useless :-/ Thanks, though. I guess I could copy that theme from the packages directory and point to the static copy instead. – mas Jan 04 '19 at 21:41

2 Answers2

3

Pelican allows for theme inheritance since version 3, but it seems to work only with the simple theme for some reason…

Here are some less or more hacky ways, still without editing the theme itself:

  • You can include HTML in Markdown, so just inserting <link rel="stylesheet" href="…"> or even <style>…</style> in page/article .md files would work. You can get the Makefile to do it automatically for every page/article. It won't break on updates and the notmyidea theme would get updated with Pelican instead of staying an old static copy.

  • Notmyidea includes a CSS file specified in CSS_FILE settings variable to allow you to use the wide variant (CSS_FILE = "wide.css" in the docs). Looking at the wide.css source, it imports main.css. So, you can create eg. custom.css, import notmyidea's main.css (like the wide.css does), and add your custom rules. And then point CSS_FILE to your custom.css.

helb
  • 3,154
  • 15
  • 21
  • I really like your first suggestion. When I open the Makefile, I am a little unsure as to how to implement it. It looks like Bash and yaml. Suggestions? – mas Jan 05 '19 at 13:52
1

Pelican does not provide theme inheritance--unless you're using the built-in 'simple' theme.

You can override a theme's templates using THEME_TEMPLATES_OVERRIDES, but there's no theme inheritance (including no templates or style inheritance) in Pelican. Yet. This is a killer feature of WordPress, in my opinion.

Also, this feature has an open feature request right now.

James
  • 1,568
  • 1
  • 15
  • 25