Skip to content

{url-filename} file name template variable would be super nice #1763

@robsheldon

Description

@robsheldon

Is your feature request related to a problem? Please describe.

I am currently archiving pages with a directory structure like: ~/archive/url.com/path/to/page.html. In the case of a URL that doesn't include a filename, like https://www.myblog.dev/blog/topic-of-the-day, I save the file under ~/archive/myblog.dev/blog/topic-of-the-day/index.html.

Currently this is a manual process. Tonight I very carefully went through the file name template variables and functions and couldn't find a way to get to the result I'm looking for. I tried several combinations of %if-empty<...> and related functions.

If there's a way to put the existing pieces together to get this, that'd be cool too.

Describe the solution you'd like

I think {url-filename} could be a helpful addition. It should be blank for URLs that don't have a file extension, so %if-empty<{url-filename}|index.html> could work. It should not be the same as {url-last-segment}, which has more complex behavior already.

{url-path-dirname} would also be helpful, which would include everything in {url-pathname} except the last segment if the last segment is a filename. (i.e., for site.io/blog/hello-world, {url-path-dirname} would be blog/hello-world; for site.io/forums/page.php, {url-path-dirname} would be forums and {url-filename} would be page.php.)

Describe alternatives you've considered (optional)

I've tried several combinations of the existing variables and functions and haven't been able to get a working version of this yet.

I can take a crack at submitting a PR for this if you'd like.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions