Sign in
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

File paths in helpers.js

  • This topic has 2 replies, 2 voices, and was last updated 1 year, 8 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #7471
    Avatar photoMike


    I am trying to write a custom helper that would work with local files. What is the preferred way to reconstruct a file path from a passed URL? url.fileURLToPath() does the job when the file URI scheme is used, but I need a universal solution. (I see that the {{imageDimensions}} helper solves this issue by referencing rendererInstance.siteConfig.domain and rendererInstance.inputDir, but it doesn’t seem to be possible for custom helpers.)


    Avatar photoMike

    It turns out that the last argument passed to a helper contains the base URL under

    I still don’t know how to get at the input directory without using __dirname.


    Avatar photoTomasz Dziuda


    Unfortunately helpers.js has no access to such data. Through the last argument you will get only access to data available for handlebars, not the renderer config.

    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.