TL;DR
Custom filename for page resources
---
title: "Kushaqua-Mud Pond"
...
resources:
- name: 'gpx'
src: 'assets/kushaqua-mudpond.gpx' #local name, easy
filename: ':siteName - :pageTitle.gpx' #Download name, polished, distinct
---
body
Right now hugo serves any page resources as they are named on the server. Makes sense, but just like it can generate alternate image URLs when resizing, I would like alternate filenames for resources.
Use Case:
- My site logs motorcycle rides
- each ride (a page) has a gpx file, and preview image, and header image
- users download the gpx to import into their app of choice
Now because of the structure of the site, the files dont need long names to knjow what they are.
/blog/ride name/assets/route.gpx
But if a user downloads a few rides, they’ll have route, route(1), etc, without know what is what.
Sure, yes I know I could just give each file a full name, but I would love to be able to use codes like
<Site Name> - <Ride Name>.gpx
similar to how :counter
is available to frontmatter today.