Relative paths for nunjucks imports
See original GitHub issueI have my nunjucks configure path set to node_modules/@govuk-frontend
that way when I import govuk macros I use a path that describes where they are coming from (and they are not confused with my own macros):
{% from 'frontend/components/radios/macro.njk' import govukRadios %}
This has been working fine (for things like the footer), however this doesn’t work when a macro template imports other macros - such as radios.
The fix for this would be to use relative paths for the imports. I have tested locally and it works for me…
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Resolving nunjucks includes using relative paths?
Nunjucks does not allow relative paths. All paths are relative to the configured base directories. Reference. Using relative paths inside an ...
Read more >Using relative paths inside an include? · Issue #1214 - GitHub
Hi, Is there a way to get the include to understand relative paths that are relative to the file that the include statement...
Read more >Nunjucks - Eleventy - Netlify
Nunjucks for Eleventy, a simpler static site generator. ... Imports (Relative Path) New in v0.8.4, Relative paths use ./ (template's directory) or ....
Read more >Layouts and Partials - Acetate
Acetate also allows you to use Nunjucks import in templates. Remember, the path will be relative to your source directory.
Read more >nunjucks-loader | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
should we also consider having an ‘all.njk’ like we do for JS and SCSS where we import all components?
Hi, @web-bert thanks for raising this.
Once the team is back on Tuesday, we’ll have a look to see if this is something we’d want to do and if so how we can work this into our backlog. We’ll keep you posted.