{"action":"created","issue":{"url":"https://api.github.com/repos/gohugoio/hugo/issues/5043","repository_url":"https://api.github.com/repos/gohugoio/hugo","labels_url":"https://api.github.com/repos/gohugoio/hugo/issues/5043/labels{/name}","comments_url":"https://api.github.com/repos/gohugoio/hugo/issues/5043/comments","events_url":"https://api.github.com/repos/gohugoio/hugo/issues/5043/events","html_url":"https://github.com/gohugoio/hugo/issues/5043","id":348213551,"node_id":"MDU6SXNzdWUzNDgyMTM1NTE=","number":5043,"title":"Hugo crashes when referencing a non-existent page","user":{"login":"hach-que","id":504826,"node_id":"MDQ6VXNlcjUwNDgyNg==","avatar_url":"https://avatars1.githubusercontent.com/u/504826?v=4","gravatar_id":"","url":"https://api.github.com/users/hach-que","html_url":"https://github.com/hach-que","followers_url":"https://api.github.com/users/hach-que/followers","following_url":"https://api.github.com/users/hach-que/following{/other_user}","gists_url":"https://api.github.com/users/hach-que/gists{/gist_id}","starred_url":"https://api.github.com/users/hach-que/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hach-que/subscriptions","organizations_url":"https://api.github.com/users/hach-que/orgs","repos_url":"https://api.github.com/users/hach-que/repos","events_url":"https://api.github.com/users/hach-que/events{/privacy}","received_events_url":"https://api.github.com/users/hach-que/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-07T08:12:07Z","updated_at":"2018-08-07T08:26:05Z","closed_at":"2018-08-07T08:12:58Z","author_association":"NONE","body":"I have a shortcode like this:\r\n\r\n```\r\n{{- $page := .Site.GetPage (.Get 0) -}}\r\n{{- if eq $page nil -}}\r\n{{- errorf \"ERROR: page is nil %s\" (.Get 0) -}}\r\n{{- else -}}\r\n[{{- $page.Title -}}]({{- ref . (.Get 0) -}})\r\n{{- end -}}\r\n```\r\n\r\nwhich is used like this:\r\n\r\n```\r\n{{< linkref \"./authenticating-users\" >}}\r\n```\r\n\r\nIf the target file doesn't exist, Hugo crashes with this stack trace:\r\n\r\n```\r\nBuilding sites … panic: runtime error: invalid memory address or nil pointer dereference [recovered]\r\n        panic: runtime error: invalid memory address or nil pointer dereference\r\n[signal 0xc0000005 code=0x0 addr=0x308 pc=0xc694c5]\r\n\r\ngoroutine 1085 [running]:\r\ntext/template.errRecover(0xc0499737f0)\r\n        /usr/local/go/src/text/template/exec.go:137 +0x1db\r\npanic(0xddca80, 0x15af010)\r\n        /usr/local/go/src/runtime/panic.go:502 +0x237\r\ngithub.com/gohugoio/hugo/hugolib.(*Page).Title(0x0, 0x0, 0x0)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/page.go:1183 +0x5\r\nreflect.Value.call(0xec0d00, 0xc0451746e0, 0x12e93, 0xec6a2b, 0x4, 0x15f07e0, 0x0, 0x0, 0xebb520, 0x1, ...)\r\n        /usr/local/go/src/reflect/value.go:447 +0x970\r\nreflect.Value.Call(0xec0d00, 0xc0451746e0, 0x12e93, 0x15f07e0, 0x0, 0x0, 0xc04712f730, 0x13, 0x4b)\r\n        /usr/local/go/src/reflect/value.go:308 +0xab\r\ntext/template.(*state).evalCall(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xec0d00, 0xc0451746e0, 0x12e93, 0x10a3d00, 0xc04286a870, 0xc0424ab1a6, ...)\r\n        /usr/local/go/src/text/template/exec.go:667 +0x4f8\r\ntext/template.(*state).evalField(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xc0424ab1a6, 0x5, 0x10a3d00, 0xc04286a870, 0xc0428646e0, 0x1, ...)\r\n        /usr/local/go/src/text/template/exec.go:557 +0xcb4\r\ntext/template.(*state).evalFieldChain(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xec0d00, 0xc0451746e0, 0x96, 0x10a3d00, 0xc04286a870, 0xc042857610, ...)\r\n        /usr/local/go/src/text/template/exec.go:525 +0x227\r\ntext/template.(*state).evalVariableNode(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xc04286a870, 0xc0428646e0, 0x1, 0x1, 0x0, 0x0, ...)\r\n        /usr/local/go/src/text/template/exec.go:513 +0x199\r\ntext/template.(*state).evalCommand(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xc04268b620, 0x0, 0x0, 0x0, 0xc049973470, 0x58d57d, ...)\r\n        /usr/local/go/src/text/template/exec.go:437 +0x718\r\ntext/template.(*state).evalPipeline(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0xc0425ddea0, 0x0, 0x0, 0xc04286a750)\r\n        /usr/local/go/src/text/template/exec.go:405 +0x116\r\ntext/template.(*state).walk(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0x10a38c0, 0xc04286a8a0)\r\n        /usr/local/go/src/text/template/exec.go:231 +0x4ac\r\ntext/template.(*state).walk(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0x10a3b00, 0xc04268b5c0)\r\n        /usr/local/go/src/text/template/exec.go:239 +0x124\r\ntext/template.(*state).walkIfOrWith(0xc049973770, 0xa, 0xe17d40, 0xc045587950, 0x16, 0xc0428665f0, 0xc04286a7e0, 0xc04268b5c0)\r\n        /usr/local/go/src/text/template/exec.go:272 +0x223\r\ntext/template.(*state).walk(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0x10a3ac0, 0xc0428ee600)\r\n        /usr/local/go/src/text/template/exec.go:236 +0x315\r\ntext/template.(*state).walk(0xc049973770, 0xe17d40, 0xc045587950, 0x16, 0x10a3b00, 0xc0428ed860)\r\n        /usr/local/go/src/text/template/exec.go:239 +0x124\r\ntext/template.(*Template).execute(0xc0428ee540, 0x10966e0, 0xc04b06d180, 0xe17d40, 0xc045587950, 0x0, 0x0)\r\n        /usr/local/go/src/text/template/exec.go:194 +0x1ed\r\ntext/template.(*Template).Execute(0xc0428ee540, 0x10966e0, 0xc04b06d180, 0xe17d40, 0xc045587950, 0xc0450640c0, 0x460247)\r\n        /usr/local/go/src/text/template/exec.go:177 +0x5a\r\nhtml/template.(*Template).Execute(0xc0428ed800, 0x10966e0, 0xc04b06d180, 0xe17d40, 0xc045587950, 0x42b050, 0x8)\r\n        /usr/local/go/src/html/template/template.go:122 +0x93\r\ngithub.com/gohugoio/hugo/tpl.(*TemplateAdapter).Execute(0xc046153c40, 0x10966e0, 0xc04b06d180, 0xe17d40, 0xc045587950, 0x0, 0x0)\r\n        /go/src/github.com/gohugoio/hugo/tpl/template.go:94 +0x7d\r\ngithub.com/gohugoio/hugo/hugolib.renderShortcodeWithPage(0x109a080, 0xc046153c40, 0xc045587950, 0x0, 0x0)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/shortcode.go:759 +0xcd\r\ngithub.com/gohugoio/hugo/hugolib.renderShortcode(0xec5204, 0x2, 0xec6ba7, 0x4, 0xec778f, 0x4, 0xc044a85e60, 0x25, 0xc044b552c0, 0x0, ...)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/shortcode.go:361 +0x549\r\ngithub.com/gohugoio/hugo/hugolib.prepareShortcodeForPage.func1(0xc044029040, 0xe42180, 0xc0440291c0, 0xc044191bc0)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/shortcode.go:281 +0x5e\r\ngithub.com/gohugoio/hugo/hugolib.(*shortcodeHandler).executeShortcodesForDelta(0xc0432cd9a0, 0xc04299ae30, 0x1b, 0xc042743d98)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/shortcode.go:442 +0xc8\r\ngithub.com/gohugoio/hugo/hugolib.handleShortcodes(0xc04299ae30, 0xc0430d6b00, 0x2a3, 0x2a3, 0x2a3, 0x2a3, 0xc042743f50, 0xc043ffd080, 0xc0480d9a00)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:610 +0x210\r\ngithub.com/gohugoio/hugo/hugolib.(*Page).prepareForRender(0xc044e30500, 0xf7b530, 0xc044359ef0)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/page.go:1268 +0x131\r\ngithub.com/gohugoio/hugo/hugolib.(*Page).initContent.func1.1(0xc044e30500, 0xc0492c4a80)\r\n        /go/src/github.com/gohugoio/hugo/hugolib/page.go:303 +0x91\r\ncreated by github.com/gohugoio/hugo/hugolib.(*Page).initContent.func1\r\n        /go/src/github.com/gohugoio/hugo/hugolib/page.go:298 +0xf4\r\n```\r\n\r\n**Hugo version:** Hugo Static Site Generator v0.45 windows/amd64 BuildDate: 2018-07-22T12:10:05Z"},"comment":{"url":"https://api.github.com/repos/gohugoio/hugo/issues/comments/410976531","html_url":"https://github.com/gohugoio/hugo/issues/5043#issuecomment-410976531","issue_url":"https://api.github.com/repos/gohugoio/hugo/issues/5043","id":410976531,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDk3NjUzMQ==","user":{"login":"bep","id":394382,"node_id":"MDQ6VXNlcjM5NDM4Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/394382?v=4","gravatar_id":"","url":"https://api.github.com/users/bep","html_url":"https://github.com/bep","followers_url":"https://api.github.com/users/bep/followers","following_url":"https://api.github.com/users/bep/following{/other_user}","gists_url":"https://api.github.com/users/bep/gists{/gist_id}","starred_url":"https://api.github.com/users/bep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bep/subscriptions","organizations_url":"https://api.github.com/users/bep/orgs","repos_url":"https://api.github.com/users/bep/repos","events_url":"https://api.github.com/users/bep/events{/privacy}","received_events_url":"https://api.github.com/users/bep/received_events","type":"User","site_admin":false},"created_at":"2018-08-07T08:26:05Z","updated_at":"2018-08-07T08:26:05Z","author_association":"MEMBER","body":"Sure, if it is a bug, we will reopen this issue. Open a thread on the forum and we can trouble shoot it there."}}
{"actor":{"display_login":"bep"}}