Today, when I change the style for my theme, the process of running the following error occurred, I upgrade hugo to the latest version, the problem is still not resolved. I really do not know how to solve, and now the site only some pages are good, some pages can not be displayed.
$ hugo env
Hugo Static Site Generator v0.36 windows/amd64 BuildDate: 2018-02-05T15:23:01Z
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.9.3"
$ hugo server --disableFastRender --noHTTPCache --ignoreCache
INFO 2018/02/11 17:49:09 Using config file: D:\Github\hugo-theme-whiteink\config.toml
Building sites … INFO 2018/02/11 17:49:09 syncing static files to D:\Gith ub\hugo-theme-whiteink\
WARN 2018/02/11 17:49:09 No translation bundle found for default language "zh-CN"
WARN 2018/02/11 17:49:09 Translation func for language zh-CN not found, use default.
WARN 2018/02/11 17:49:09 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.
INFO 2018/02/11 17:49:09 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
ERROR 2018/02/11 17:49:09 Failed to render "theme/_default/single.html": runtime error: invalid memory address or nil pointer dereference
| ZH-CN
+------------------+-------+
Pages | 115
Paginator pages | 0
Non-page files | 1
Static files | 20
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 93 ms
WARN 2018/02/11 17:49:09 Skip i18nDir: GetFileAttributesEx D:\Github\hugo-theme-whiteink\i18n: The system cannot find the file specified.
Watching for changes in D:\Github\hugo-theme-whiteink\{content,data,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/hugo-theme-whiteink/ (bind address 127.0.0.1)
Press Ctrl+C to stop
It’s not possible tell the problem from that information. You’ll need to share the site source (or a minimum replica of the that that shows the problem – if you cannot share the original source).
Thank you for your suggestion, my source code is kept in github, README.md has given test command, I re-experiment a bit and found that the problem persists.
This link branch is the content of the site, the theme stored in the master branch. The test need to copy the master branch to the themes directory. The site config.toml points WhiteInk as the site theme. The README.md shows commands for theme testing.
# test
$ git clone -b Demo-website https://github.com/yi-Xu-0100/hugo-theme-whiteink.git
$ cd hugo-theme-whiteink/
$ git clone -b master https://github.com/yi-Xu-0100/hugo-theme-whiteink.git themes/WhiteInk
$ hugo server
# Web Server is available at http://localhost:1313/hugo-theme-whiteink/
It’s because, in the post.html partial, you are unconditionally trying to refer to .Prev.URL and .Next.URL without first checking if .Prev and .Next exist… for example, the .Prev won’t exist on the first post, and the .Next won’t on the last post.
So replace that piece of code with something like:
{{ with .Prev }}
<a class="prev-page" href={{ .URL }}>
上一页
</a>
{{ end }}
{{ with .Next }}
<a class="next-page" href={{ .URL }}>
下一页
</a>
{{ end }}
As a side, you can avoid doing that by putting the demo site (say exampleSite) in the root of the theme repo, and setting themesDir = "../../" in exampleSite/config.toml.
Then you just need to clone the repo, cd to exampleSite and run hugo.