Skip to content

Default path resolution for partials when a directory is passed #11117

Open
@UtkarshVerma

Description

@UtkarshVerma

Hugo's partial resolution does not currently support directories as paths. Having them would be convenient as they would allow more modular and self contained Hugo modules. For example, I'm currently developing something like this:

layouts/partials/
-> identicon/
----> color.html
----> main.html
----> path.html

To use this module, I have to explicitly state that I want to include the main partial:

{{ partial "identicon/main" . }}

However, it makes more sense to call {{ partial "identicon" }} and have it resolve to identicon/main.html or identicon/index.html by default.

To attain this behaviour with the current release, I have to create another file partials/identicon.html which simply calls partials/identicon/main.

This leads to an extra file in the partial tree, which is unpreferable in terms of organization:

layouts/partials/
-> identicon/
----> color.html
----> main.html
----> path.html

-> identicon.html

I propose a path resolving mechanism be implemented in Hugo which resolves directory includes either main.html or index.html. It would make the file structure more organized and self contained.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions