Skip to content

Conversation

@bep
Copy link
Member

@bep bep commented Oct 24, 2025

For this and similar mounts in a theme:

[[module.mounts]]
source = 'node_modules/bootstrap'
target = 'assets/vendor/bootstrap'

We first check the theme itself, then the project root.

For backwards compatibility, we also make any ../../node_modules/... source paths into node_modules/... paths when defined in themes/modules.

Fixes #14089

@bep bep force-pushed the feat/mountnodemodfromtheme-19196 branch 5 times, most recently from adc7164 to 0b159f0 Compare October 24, 2025 11:56
For this and similar mounts in a theme:

```toml
[[module.mounts]]
source = 'node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
```

We first check the theme itself, then the project root.

For backwards compatibility, we also make any `../../node_modules/...` `source` paths into `node_modules/...` paths when defined in themes/modules.

Fixes gohugoio#14089
@bep bep force-pushed the feat/mountnodemodfromtheme-19196 branch from 0b159f0 to 90af7b6 Compare October 24, 2025 12:10
@bep bep requested a review from Copilot October 24, 2025 13:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds special handling for node_modules mounts in Hugo themes/modules. When a theme/module defines a mount with source starting with node_modules/, Hugo will now check the theme directory first, then fall back to the project root if not found.

  • Implements a two-tier lookup strategy for node_modules paths in theme/module mounts
  • Adds backwards compatibility for the ../../node_modules/... pattern previously used to reference project-level node_modules
  • Normalizes ../../node_modules/... paths to node_modules/... when defined in themes/modules

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/collect.go Adds nodeModulesRoot() helper and implements special case logic in normalizeMounts() to handle node_modules paths with fallback to project root
hugofs/hugofs_integration_test.go Adds integration test covering the three scenarios: project-level node_modules, backwards-compatible ../../ prefix, and theme-level node_modules

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bep bep requested a review from jmooring October 24, 2025 13:27
Copy link
Member

@jmooring jmooring left a comment

Choose a reason for hiding this comment

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

I verified that this addresses google/docsy#2345.

@bep bep merged commit 809ebe0 into gohugoio:master Oct 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants