Skip to main content

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.html page 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_URL is not consumed by the plugin itself —
it is only needed if you want Pelican's link helpers to resolve /random.
Set it to match RANDOM_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.10
  • Pelican >= 4.5
  • Jinja2 (bundled with Pelican)

License

MIT License © Wei Lee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pelican_random_article-0.2.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pelican_random_article-0.2.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pelican_random_article-0.2.1.tar.gz.

File metadata

  • Download URL: pelican_random_article-0.2.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pelican_random_article-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f57802e14c2e38f3aa8b6c87e66dead0f59b1013361c77521c37a6fbe480bedc
MD5 4b7d5e477b64a1c0bdf2247ab9b75a42
BLAKE2b-256 90cf7d7e51b020fe08dca6601b0617b115343c857bb60b1dd11e5ab845fe09ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for pelican_random_article-0.2.1.tar.gz:

Publisher: publish-to-pypi.yaml on Lee-W/pelican-random-article

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pelican_random_article-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pelican_random_article-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31933df3d3363411362e6a1620dd3b544bb7740fa3d369c2d394e022095d225d
MD5 2dc88cb127d1c08cf47dd5338d0afb76
BLAKE2b-256 4e3af28c120c87461572003b5559f692d34a2b702957a85af3667f8ff59c7c81

See more details on using hashes here.

Provenance

The following attestation bundles were made for pelican_random_article-0.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yaml on Lee-W/pelican-random-article

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page