Pelican Custom CSS
Pelican Custom CSS makes it easy to embed custom CSS into individual Pelican articles and pages. This repository is a fork of Pelican CSS originally created by Jorge Maldonado Ventura that has been converted to use the Pelican namespace plugin structure and published to PyPi.
Installation
To install pelican-custom-css run the following command:
pip install pelican-custom-css
Configuration
Namespace plugins can be configured in a few ways, this section is taken straight from the Pelican Documentation for plugins. If you leave the PLUGINS setting as default (None), Pelican will automatically discover namespace plugins and register them. If, on the other hand, you specify a PLUGINS setting as a list of plugins, this auto-discovery will be disabled. At that point, only the plugins you specify will be registered, and you must explicitly list any namespace plugins as well.
If you are using the PLUGINS setting, you can specify plugins in two ways. The first method specifies plugins as a list of strings. Namespace plugins can be specified either by their full names (pelican.plugins.myplugin) or by their short names (myplugin):
PLUGINS = ['package.myplugin',
'namespace_plugin1',
'pelican.plugins.namespace_plugin2']
Alternatively, you can import them in your settings file and pass the modules:
from package import myplugin
from pelican.plugins import namespace_plugin1, namespace_plugin2
PLUGINS = [myplugin, namespace_plugin1, namespace_plugin2]
Next, you will need to create a css directory in your content directory for your custom styles to live in.
website/
├── content
│ ├── css/
│ │ ├── your_custom_style1.css
│ │ └── your_custom_style2.css
│ ├── article1.md
│ └── pages
│ └── about.md
└── pelicanconf.py
And then add each resource as a comma-separated file name with the CSS tag:
Title: Mejor sin Wordpress
Date: 2017-02-09 18:51
Tags: programación, Wordpress, generador de páginas estáticas, generador de sitios web estáticos, rendimiento, eficiencia, comodidad, desventajas
Category: Desarrollo web
Author: jorgesumle
Slug: mejor-sin-wordpress
CSS: your_custom_style1.css, your_custom_style2.css
Finally, in your base template (likely named base.html), you need to add the following in your <head> tag:
{% if article %}
{% if article.styles %}
{% for style in article.styles %}
{{ style|format(SITEURL) }}
{% endfor %}
{% endif %}
{% endif %}
So, the template I use for my blog now looks like the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8">
<title>{% block title %} {{SITENAME}} {% endblock %}</title>
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/style.css" type="text/css">
{% if article %}
{% if article.styles %}
{% for style in article.styles %}
{{ style|format(SITEURL) }}
{% endfor %}
{% endif %}
{% endif %}
</head>
<body>
<div class=container>
{% block header %}
{% include "header.html" %}
{% endblock %}
<div class="content">
{% block content %} {% endblock %}
</div>
{% block footer %}
{% include "footer.html" %}
{% endblock %}
</div>
</body>
</html>
The previous code only works for articles. For most people, that's enough. If you want to enable custom CSS in pages too insert the following code your <head> tag...
{% if page %}
{% if page.styles %}
{% for style in page.styles %}
{{ style|format(SITEURL) }}
{% endfor %}
{% endif %}
{% endif %}
That's it! You can now generate and publish your site normally, for example using ghp-import if you're using Github Pages or the standard make html or make publish commands from Pelican and your CSS will be copied and referenced in the right places.
Metadata
Release files for pelican-custom-css 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pelican_custom_css-0.0.4.tar.gz | 52.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pelican_custom_css-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.1 kB
Release files / pelican_custom_css-0.0.4.tar.gz
| Download URL | pelican_custom_css-0.0.4.tar.gz |
|---|---|
| Size | 52.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fe45dd8a76e74f164dc743196d7b2b561a77d102152609327bef3cc28944254
|
|
BLAKE2b-256 checksum How to use checksums |
7e2b63e6735faa37b3917fa79da25175ea2cd9dcd14eeac100ede06392d63c6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / pelican_custom_css-0.0.4-py3-none-any.whl
| Download URL | pelican_custom_css-0.0.4-py3-none-any.whl |
|---|---|
| Size | 40.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e9c02087ee6e2d7e1b324e7c6ce1d77c51c270d7c0b80d2073f3ca4368b62aa
|
|
BLAKE2b-256 checksum How to use checksums |
a1fb2d41c16bfa9d1b3883326fc0039c548e19302b5267bbf929a8e7260b864a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for pelican-custom-css 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.