Metadata-Version: 2.4
Name: render-engine-clean-urls
Version: 0.1.0
Summary: Render-engine plugin that mirrors single pages to /<slug>/index.html so clean URLs resolve alongside the original .html files.
Author-email: Kevin Miller <kjaymiller@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Kevin Miller
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/kjaymiller/render-engine-clean-urls
Project-URL: Source, https://github.com/kjaymiller/render-engine-clean-urls
Project-URL: Issues, https://github.com/kjaymiller/render-engine-clean-urls/issues
Keywords: render-engine,static-site,plugin,clean-urls
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: render-engine
Requires-Dist: pluggy
Dynamic: license-file

# render-engine-clean-urls

A [render-engine](https://github.com/render-engine/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)
- `Collection`s and the pages they generate
- `DataObject`s
- Pages with an explicit class-level `path_name`
- Pages with a non-default `routes` value

## Install

```bash
pip install render-engine-clean-urls
```

Or with `uv`:

```bash
uv add render-engine-clean-urls
```

## Usage

```python
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`:

```python
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](LICENSE).
