Suggestion: Ability to rename page resources intended for download

Custom filename for page resources

title: "Kushaqua-Mud Pond"
- name: 'gpx'
  src: 'assets/kushaqua-mudpond.gpx'  #local name, easy
  filename: ':siteName - :pageTitle.gpx' #Download name, polished, distinct

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.

use HTML5 and set the download attrib in the links!


<a href="path/to/file" download="renamed.txt">Download</a>
<a href="downloads/export.xlsx" download="Data-Export.xlsx">Download Export</a>

Perfect, thank you. I wasn’t aware of a way to set this from html without modifying server headers.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.