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

Absolute paths not working in mount #6622

Closed
kvakulo opened this issue Dec 16, 2019 · 0 comments · Fixed by #6642
Closed

Absolute paths not working in mount #6622

kvakulo opened this issue Dec 16, 2019 · 0 comments · Fixed by #6642
Labels
Bug
Milestone

Comments

@kvakulo
Copy link

@kvakulo kvakulo commented Dec 16, 2019

What version of Hugo are you using (hugo version)?

Hugo Static Site Generator v0.61.0-9B445B9D windows/amd64 BuildDate: 2019-12-11T08:29:13Z

Does this issue reproduce with the latest release? ✔️


When trying to use an absolute path in a mount for the main project, e.g.

{
  "module":{
    "mounts":[
      {
        "source":"C:\\my-awesome-content",
        "target":"content"
      }
    ]
  }
}

The mount is not getting set and the output of hugo config mounts is:

{
   "path": "project",
   "dir": "c:\\projects\\my-project",
   "mounts": [
      {
         "source": "content",
         "target": "content"
      }
   ]
}

However according to the documentation it should be supported:

: The source directory of the mount. For the main project, this can be either project-relative or absolute and even a symbolic link. For other modules it must be project-relative.

The issue seems to be around here:

sourceDir := filepath.Join(dir, mnt.Source)

As the project directory is always joined with the mount source.

When changing the logic to:

sourceDir := "";

if filepath.IsAbs(mnt.Source) {
	sourceDir = mnt.Source;
} else {
	sourceDir = filepath.Join(dir, mnt.Source)
}

Then the output of hugo config mounts is correct:

{
   "path": "project",
   "dir": "c:\\projects\\my-project",
   "mounts": [
      {
         "source": "C:\\my-awesome-content",
         "target": "content"
      }
   ]
}

I'm sure this isn't the solution, but I hope it can illustrate the issue 😄

@bep bep added this to the v0.62 milestone Dec 19, 2019
@bep bep added the Bug label Dec 19, 2019
bep added a commit to bep/hugo that referenced this issue Dec 19, 2019
@bep bep closed this in #6642 Dec 19, 2019
bep added a commit that referenced this issue Dec 19, 2019
Fixes #6622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.