Repository navigation
tpl/partials: Support relative partial paths from within partials - #15376
Merged
Merged
Conversation
A partial name starting with "./" or "../" is resolved relative to the directory of the calling partial. Calling with a relative path from any other template, or with a path that resolves outside the partials directory, is an error. Closes gohugoio#15373 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Deferred blocks do not preserve partial ownership, and IncludeCached lacks end-to-end relative-path coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds relative ./ and ../ partial-path resolution within partial templates, including decorator contexts, tests, and documentation.
Changes:
- Resolves relative paths and prevents invalid traversal.
- Tracks partial and decorator ownership.
- Updates include APIs, tests, and documentation.
| File | Summary |
|---|---|
tpl/tplimpl/templatetransform.go |
Tracks decorator ownership. |
tpl/tplimpl/templatestore.go |
Resolves relative paths and stores ownership metadata. |
tpl/partials/partials.go |
Applies resolution to partial APIs. |
tpl/partials/partials_integration_test.go |
Tests relative paths and errors. |
docs/content/en/functions/partials/IncludeCached.md |
Documents cached relative-path support. |
docs/content/en/functions/partials/Include.md |
Documents relative partial paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Deferred blocks defined inside a partial did not carry the owner's category, so relative partial paths in templates.Defer blocks failed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
16 tasks done
bep
added a commit
that referenced
this pull request
Oct 11, 2026
b732eba6c theme: Migrate aliases to a redirects data file 1f7267422 content: Reorganize host and deploy section 52a9a7601 content: Add another piping example 480f2dbcd content: Remove description formatting and fix interval glossary 7363275a3 content: Make glossary entries comply with style guide 62b3d90ee content: Remove reference to "new" feature 8dc1bb3e8 content: Clarify and reference read restrictions e7b4f60c8 content: Update list of reserved front matter field names 6784c2133 content: Make cascade and permalinks config pages symmetrical e535d9dd6 content: Refer to WinGet by its official name 34a5bcc9c content: Modify WinGet installation commands e4b9e67b3 content: Document changes to the project config file requirement 8601cfffb content: Add another example to collections.Append b6efb06e8 content: Refer to directories by their component or default names 4bac9ad36 content: Fix typos c31c64194 content: Use collapsed link reference 19a1e1fa6 content: Clarify page matcher definition bc18dd113 theme: Use relative partial paths where possible 6fd429b84 content: Clarify default cleanDestinationDir config 85cb91591 Update HUGO_VERSION to 0.167.0 fe4d3a519 content: Updates for v0.167.0 2d48cdbeb Merge branch 'tempv0167' a2c900dc7 tocss: Confine Sass import fallbacks to the allowed read paths 6cb28f843 js: Confine ESBuild's fallback resolver to the allowed read paths f7037bcd7 misc: Update cspell ignore list 54c705503 misc: Refine cspell config 2d644c5fa content: Hyphenate command-line when used as an adjective 268cf7849 Merge commit '73171acbb132bdf1387823b744e9d873d39b2924' a38f69549 tpl/partials: Support relative partial paths from within partials (#15376) git-subtree-dir: docs git-subtree-split: b732eba6c2642cdbfd05b9ed761d4831af5fe541
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A partial name starting with "./" or "../" is resolved relative to the
directory of the calling partial. Calling with a relative path from any
other template, or with a path that resolves outside the partials
directory, is an error.
Closes #15373
Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com