Hugo: destination/PublishDir is relative to source directory

Created on 25 Jun 2015  路  1Comment  路  Source: gohugoio/hugo

I'm trying to do an out-of-tree build for a bunch of materials related to a course I'm teaching. For other tools (e.g., the C++ compiler), any output paths are interpreted relative to the current (out-of-tree) working directory. For instance:

[~/course/build]$ c++ -c ../src/foo.cpp -o obj/foo.o

will result in a foo.o being created in the ~/course/build/obj directory. With Hugo, however:

[~/course/build]$ hugo --source=../website --destination=website

I end up with generated files in the ~/course/website/website directory.

It looks like various things in commands/hugo.go use helpers.AbsPathify(viper.GetString("PublishDir")), which constructs an absolute path by joining the _source_ directory and a relative path. If there were another helper that did the same from the _current_ directory, Hugo would behave more like other tools do, making out-of-tree builds (potentially with read-only sources) easier to do.

WontFix

>All comments

So this isn't so much of a bug as it's a feature. The way it's designed to work (and does work) is that all relative paths are based off of the source directory (a relative path given there is based off the CWD).

Any absolute paths provided will be treated as absolute.

There are a few reasons for this:

  1. It's how a few others work so there was precedence.
  2. It makes it so config files can use relative paths. If we did as you suggest than we would need to treat flags differently from ENV variables and config parameters as it pertains to paths which to me feels odd.
Was this page helpful?
0 / 5 - 0 ratings