Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow referencing Handlebars partials by filename instead of subdirectory #8

Open
davegomez opened this issue Feb 28, 2023 · 2 comments
Labels
enhancement New feature or request 📦 handlebars

Comments

@davegomez
Copy link

davegomez commented Feb 28, 2023

Operating system

macOS Ventura 13.2.1

Eleventy

2.0.0

Describe the bug

Partials inside subdirectories in _includes are not found.

Is there any configuration option or syntax that allows me to access partials inside subdirectories?

Reproduction steps

Having the following files:

src/views/index.hbs
src/_includes/navbar.hbs
src/_includes/ui/button.hbs

navbar.hbs uses {{> button }} but I'm getting the following error when trying to compile the view:

[11ty] 1. Having trouble rendering hbs template ./src/views/index.hbs (via TemplateContentRenderError)
[11ty] 2. The partial button could not be found (via Error)

If I move the file one level up to the _includes directory it will work, but our project has hundreds of partials and we need the directories to keep them organized.

Expected behavior

No response

Reproduction URL

No response

Screenshots

No response

@davegomez
Copy link
Author

I found Eleventy is actually processing all the partials inside subdirectories, the problem is that I have to extend the route if I want to use them, so it would be {{> ui/button }} instead of {{> button }}.

I wonder if there is any way to avoid this and just use the name of the partial to avoid changing the hundreds of pages we already have in production?

@zachleat
Copy link
Member

Is this a duplicate of 11ty/eleventy#2601?

@zachleat zachleat added the duplicate This issue or pull request already exists label Mar 21, 2023
@zachleat zachleat added enhancement New feature or request and removed duplicate This issue or pull request already exists labels Jul 10, 2024
@zachleat zachleat changed the title Handlebars partials in subdirectories are not found Allow referencing Handlebars partials by filename instead of subdirectory Jul 10, 2024
@zachleat zachleat transferred this issue from 11ty/eleventy Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 📦 handlebars
Projects
None yet
Development

No branches or pull requests

2 participants