Skip to content

tpl/partials: Support relative partial paths from within partials - #15376

Merged
bep merged 2 commits into
gohugoio:masterfrom
bep:feat/relativepartials-15373
Sep 24, 2026
Merged

bep merged 2 commits into
gohugoio:masterfrom
bep:feat/relativepartials-15373

Conversation

@bep

@bep bep commented Sep 23, 2026

Copy link
Copy Markdown
Member

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

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>
@bep
bep marked this pull request as ready for review September 23, 2026 18:14
@bep
bep requested a lite review from Copilot September 24, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

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.

Comment thread tpl/tplimpl/templatestore.go
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>
@bep
bep merged commit bd1588b into gohugoio:master Sep 24, 2026
4 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support relative path calls in partials

2 participants