Skip to content

snippet helper copyFile #991

Open

Description

@mikebarkmin

Sometimes you may want to include an external file in your project. Currently, you can either encode the file as base64 using a snippet helper, or rely on a separate bash script that runs beforehand.

It would be helpful to introduce a new helper: copyFile. This helper would copy the specified file into the output directory, prefix the filename with a random string to avoid name clashes, and return the new path.

Here’s an example usage:

<img src="{{copyFile '../../../images/logo.png'}}" />

In some cases, you might want to copy a file as part of the build process without including its path in the rendered output. To support this use case, the helper could accept an optional silent=true flag:

{{copyFile '../../../docs/README.pdf' silent=true}}

This would copy the file to the output directory as usual, but return nothing to the template.

Activity

  1. jneug commented on Jan 23, 2026

    @jneug

    Maybe add an id attribute (or permid to keep naming consistent) that allows referencing the file later on the page or from other pages?

    <img src="{{copyFile '../../../images/logo.png' permid=img-logo}}"/>
    
    ...
    
    <img src="{{copyFile permid=img-logo}}"/>
    

    This could be done by looking at the source path and coping the same file only once, using a dedicated attribute would make changing the source much easier.

  2. mikebarkmin commented on Jan 26, 2026

    @mikebarkmin
    MemberAuthor

    That's a good idea. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions