A Pelican plugin that generates a /random page redirecting visitors to a random article.
Project description
pelican-random-article
pelican-random-article is a Pelican plugin that automatically generates a /random page.
Visiting /random instantly redirects the reader to a randomly chosen article — just like wiwi.blog/random.
Features
- Generates a static
random/index.htmlpage at build time. - Picks a random article client-side using JavaScript — no server required.
- Works with any Pelican theme; no template changes needed.
- Configurable output path via
pelicanconf.py.
Installation
pip install pelican-random-article
Or with uv:
uv add pelican-random-article
Usage
1. Enable the plugin in pelicanconf.py
PLUGINS = [
# ... your other plugins ...
"pelican.plugins.random_article",
]
2. (Optional) Add a link in your navigation
Point any link to /random (or wherever RANDOM_ARTICLE_SAVE_AS points):
<a href="{{ SITEURL }}/random/">Random</a>
3. Build your site
pelican content
The plugin will write output/random/index.html automatically.
Configuration
Add these to pelicanconf.py to customise the output path:
# Default values shown below
RANDOM_ARTICLE_SAVE_AS = "random/index.html"
Note:
RANDOM_ARTICLE_URLis not consumed by the plugin itself —
it is only needed if you want Pelican's link helpers to resolve/random.
Set it to matchRANDOM_ARTICLE_SAVE_AS:
RANDOM_ARTICLE_URL = "random/"
RANDOM_ARTICLE_SAVE_AS = "random/index.html"
> ```
## How it works
At build time the plugin:
1. Connects to Pelican's `article_generator_finalized` signal.
2. Collects all published article URLs.
3. Renders a tiny HTML page that contains the full URL list as a JSON array.
4. On page load, JavaScript picks a random entry and calls `window.location.href`.
Because the redirect happens client-side, the page is completely static and
requires no server-side logic.
## Requirements
* Python >= 3.11
* Pelican >= 4.5
* Jinja2 (bundled with Pelican)
## License
MIT License © Wei Lee
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pelican_random_article-0.2.0.tar.gz.
File metadata
- Download URL: pelican_random_article-0.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
838d9ef8fc74acc60e4dc8f4e5bd32b94b8f018b3b8c214b5711427ff8723e36
|
|
| MD5 |
3dbc832f1c4e5379cfc4b0f3df64f138
|
|
| BLAKE2b-256 |
d10827eb033598b99be708e9f79429e98d7b2a180129641bb08d7af23a54c42a
|
Provenance
The following attestation bundles were made for pelican_random_article-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yaml on Lee-W/pelican-random-article
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_random_article-0.2.0.tar.gz -
Subject digest:
838d9ef8fc74acc60e4dc8f4e5bd32b94b8f018b3b8c214b5711427ff8723e36 - Sigstore transparency entry: 1107686324
- Sigstore integration time:
-
Permalink:
Lee-W/pelican-random-article@d8d17ec9f6fa6a86e5e3ef8520391256e31fcdb4 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Lee-W
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yaml@d8d17ec9f6fa6a86e5e3ef8520391256e31fcdb4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pelican_random_article-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pelican_random_article-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4338a3758b1f5797344211baa484565b58f3e15622ef11a04ae8385861d6c743
|
|
| MD5 |
500d315d079b502aa7390ef648558f00
|
|
| BLAKE2b-256 |
b340d3a1eeb7ef7360059f7d761be0bfe85b953a44e461b80d23adb3fe404033
|
Provenance
The following attestation bundles were made for pelican_random_article-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yaml on Lee-W/pelican-random-article
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_random_article-0.2.0-py3-none-any.whl -
Subject digest:
4338a3758b1f5797344211baa484565b58f3e15622ef11a04ae8385861d6c743 - Sigstore transparency entry: 1107686327
- Sigstore integration time:
-
Permalink:
Lee-W/pelican-random-article@d8d17ec9f6fa6a86e5e3ef8520391256e31fcdb4 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Lee-W
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yaml@d8d17ec9f6fa6a86e5e3ef8520391256e31fcdb4 -
Trigger Event:
push
-
Statement type: