Skip to main content

Render-engine plugin that mirrors single pages to /<slug>/index.html so clean URLs resolve alongside the original .html files.

Project description

render-engine-clean-urls

A render-engine plugin that mirrors each single page's output to <slug>/index.html, so the page is reachable at the clean URL /<slug>/ in addition to the original /<slug>.html.

The plugin is non-destructive: the original <slug>.html file is left in place, and a copy is written at <slug>/index.html. Existing internal links of either form continue to work.

What gets rewritten

The plugin only mirrors top-level single pages that use the default route (["./"]). The following are skipped:

  • The homepage (slug index by default)
  • Collections and the pages they generate
  • DataObjects
  • Pages with an explicit class-level path_name
  • Pages with a non-default routes value

Install

pip install render-engine-clean-urls

Or with uv:

uv add render-engine-clean-urls

Usage

from render_engine import Page, Site
from render_engine_clean_urls import CleanURLsPlugin

app = Site()
app.plugin_manager.register_plugin(CleanURLsPlugin)

@app.page
class About(Page):
    content_path = "about.html"

After app.render(), the output directory contains both:

output/about.html
output/about/index.html

so /about.html and /about/ both resolve to the same content.

Configuration

Skip additional slugs by registering with Site.register_plugins:

app.register_plugins(
    CleanURLsPlugin,
    CleanURLsPlugin={"skip_slugs": {"index", "robots"}},
)

skip_slugs defaults to {"index"}.

How it works

The plugin implements render-engine's post_build_site hook. After all pages have been rendered to disk, it walks site.route_list, identifies the single Page entries that should be mirrored, and copies each output/<slug>.html to output/<slug>/index.html.

Because the work happens after the normal build, the plugin doesn't change any page metadata, URLs returned by url_for(), or the site map.

License

MIT — see LICENSE.

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

render_engine_clean_urls-0.1.0.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.

render_engine_clean_urls-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file render_engine_clean_urls-0.1.0.tar.gz.

File metadata

  • Download URL: render_engine_clean_urls-0.1.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.12

File hashes

Hashes for render_engine_clean_urls-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fee32f7df5c77f64dc8da92e616077c178007f3b979dc6065f42ad871f67949a
MD5 60a4075197ee0ae2153c054ab5acb178
BLAKE2b-256 78838da43d139189c28432d66df088b69c9be994639681588871bc127936f2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for render_engine_clean_urls-0.1.0.tar.gz:

Publisher: publish.yml on kjaymiller/render-engine-clean-urls

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

File details

Details for the file render_engine_clean_urls-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for render_engine_clean_urls-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7406897782b0cb914a8a28d5a320eee430d115ad41c248745bb65613b0b5c81f
MD5 94004bf191a154d1997f9118c4ab1280
BLAKE2b-256 911caf73d875c42c3828b22ba0fa4ebd99a49654c8c15f04e4325e5b05b7a74e

See more details on using hashes here.

Provenance

The following attestation bundles were made for render_engine_clean_urls-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kjaymiller/render-engine-clean-urls

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