Hugo: gitinfo: Support symbolic links

Created on 3 Dec 2016  路  15Comments  路  Source: gohugoio/hugo

Looks like a missing slash in the beginning.

See https://discuss.gohugo.io/t/hugo-0-18-release-scheduled-for-mon-19th-december-please-help-test-test-test/4726/17

@mdhender I assume the doc site you build is an actual clone of Hugo, i.e. a Git repo and not a zip file?

What OS are you running?

Enhancement Stale

All 15 comments

macOS. I pulled spf13/hugo this morning, did a cd into the docs directory and started hugo --server.

$ uname -a
Darwin macpro.local 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
macpro:docs mdhender$ git remote -v
mdhender    https://github.com/mdhender/hugo.git (fetch)
mdhender    https://github.com/mdhender/hugo.git (push)
origin  https://github.com/spf13/hugo (fetch)
origin  https://github.com/spf13/hugo (push)
macpro:docs mdhender$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

Could be a problem with symbolic links. My directory is on a separate mount. If I go there directly, it works as expected:

$ hugo version && hugo server
Hugo Static Site Generator v0.18-DEV-BA8A00A BuildDate: 2016-12-03T10:54:19-06:00
Started building sites ...
Built site for language en:
0 draft content
0 future content
0 expired content
205 regular pages created
72 other pages created
0 non-page files copied
0 paginator pages created
0 groups created
58 tags created
total in 450 ms
Watching for changes in /Volumes/ssda/mdhender/Software/go/src/github.com/spf13/hugo/docs/{data,content,layouts,static}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

If I go using the symbolic link, I get the GitInfo error:

$ hugo version && hugo server
Hugo Static Site Generator v0.18-DEV-BA8A00A BuildDate: 2016-12-03T10:54:19-06:00
Started building sites ...
ERROR: 2016/12/03 14:30:54 gitinfo.go:63: Failed to find GitInfo for "Users/mdhender/Software/go/src/github.com/spf13/hugo/docs/content/troubleshooting/strange-eof-error.md"
Built site for language en:
0 draft content
0 future content
0 expired content
205 regular pages created
72 other pages created
0 non-page files copied
0 paginator pages created
58 tags created
0 groups created
total in 452 ms
Watching for changes in /Users/mdhender/Software/go/src/github.com/spf13/hugo/docs/{data,content,layouts,static}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

This issue has been automatically marked as stale because it has not been commented on for at least six months.

The resources of the Hugo team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

I just encountered this bug -- see #3698 -- and another one too -- would be great to get both fixed if at all possible! Please don't close this bug ticket at least!

This has just bit me.

  • I use a Mac.
  • I have an external storage volume which is formatted case-sensitive for git-based and other projects where case sensitivity matters (Try checking out the Linux kernel without it).
  • I symlink it from /Volumes/My-Storage-Volume/GitHub into a folder inside /Users/raph/Documents/GitHub

Interestingly, it does not seem to affect all of Hugo. Instead, I get the failure ERROR 2017/08/23 10:16:36 Symbolic links for directories not supported, skipping '/Users/raph/Documents/GitHub/stormmq/website/input/hugo/layouts'.

I also have file-pointing symlinks inside layouts, eg layouts/rss.xml => _default/rss.xml. This is because I wanted to experiment with alternatives for RSS feeds.

Hugo really, really should support symlinks if at all possible, ideally by just treating them as any other POSIX tool would.

Interestingly, it does not seem to affect all of Hugo.

It bails after the first error.

Does it? Generation seems to be continuing...

I'm also now getting issues with:-

  • partialCached not finding files when they are symlinks inside of layout/partials
  • readFile not finding files when they use .. as part of the file name

In both cases, the resolved symlinks or relative path syntaxes point outside of the root. This is because I need to reference resources created before Hugo runs.

I've sorted this for now by using a .gitignore and copying files into the layouts/partials before running Hugo, but it's not really maintainable, as a cursory glance at the folder and file hierarchy doesn't reflect the generated one. Indeed, another editor of my templates would be mightly confused.

I realize Hugo's written in Go, so presumably it's not using the standard POSIX functions for resolving file paths (as they are written in C). However... it should be using a compatible algorithm. Generally speaking, symbolic links, relative file paths and the like should be transparent to it.

OK, a bit more information.

The error message ERROR 2017/08/23 10:16:36 Symbolic links for directories not supported, skipping '/Users/raph/Documents/GitHub/stormmq/website/input/hugo/layouts' has nothing to do with the presence of a symbolic folder link. It occurs once for each file with a relative symbolic link inside layouts, ie the error message does not reflect the cause.

Does it? Generation seems to be continuing...

Yes, by bail i mean: We give up the GitInfo part, but you will get a site.

Pulled and rebuilt Hugo a few minutes ago with go 1.8. I'm not having the symbolic link issue now.

macpro:docs mdhender$ hugo version && hugo server
Hugo Static Site Generator v0.27-DEV-7231D5A8 darwin/amd64 BuildDate: 2017-08-23T20:33:20-06:00
Started building sites ...
Built site for language en:
0 of 6 drafts rendered
0 future content
0 expired content
225 regular pages created
51 other pages created
1 non-page files copied
15 paginator pages created
16 categories created
total in 364 ms
Watching for changes in /Users/mdhender/Software/go/src/github.com/gohugoio/hugo/docs/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

No problems with 1.9beta2, either.

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

I'm getting the same problem on Windows 10. Attempting to use .GitInfo.AuthorDate but I get the error:

Error while rendering "page" in "blog\\": template: D:\Web\blackthread_hugo\layouts\_default\single.html:20:11: executing "main" at <partial "page-meta.h...>: error calling partial: template: partials/page-meta.html:9:17:
executing "partials/page-meta.html" at <.GitInfo.AuthorDate>: can't evaluate field AuthorDate in type *gitmap.GitInfo

The same happens if I try to access any other .GitInfo fields. If I output just {{ .GitInfo }} the what I see in my html is <nil>.

EDIT: running hugo serve -D --enableGitInfo works. So the problem is that it's not getting picked up from config.toml

I've tried

  • enableGitInfo = "true"
  • enableGitInfo = true
  • EnableGitInfo = "true"
  • EnableGitInfo = true

EDIT EDIT: Hugo version v0.32.4 windows/amd64 BuildDate: 2018-01-26T12:30:15+11:00

The same. Both enableGitInfo = true and hugo serve -D --enableGitInfo not wokrs.

<.GitInfo.AuthorDate>: can't evaluate field AuthorDate in type *gitmap.GitInfo

Hugo Static Site Generator v0.38.2 windows/amd64 BuildDate: 2018-04-09T08:17:46Z
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.10"

Same issue here

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikolas picture nikolas  路  3Comments

VoidingWarranties picture VoidingWarranties  路  3Comments

crash-dive picture crash-dive  路  3Comments

vielmetti picture vielmetti  路  3Comments

marekr picture marekr  路  3Comments