Build fails on netlify, Although it works fine locally

Hey!

I am trying to move my blog from Gutenberg to Hugo. I just did a normal hugo new and created a website. Transferred all blog posts and added a theme OnetwoThree. If i do hugo serve, all works fine . But if I put the same code on github and let netlify deploy the website. I get this huge error, which I am not able to figure out how to fix.

6:38:00 PM: Build ready to start
6:38:03 PM: Fetching cached dependencies
6:38:03 PM: Starting to download cache of 37.0MB
6:38:03 PM: Finished downloading cache in 371.841601ms
6:38:03 PM: Starting to extract cache
6:38:04 PM: Finished extracting cache in 1.001112851s
6:38:05 PM: Finished fetching cache in 1.483121404s
6:38:05 PM: Starting to prepare the repo for build
6:38:07 PM: Preparing Git Reference refs/heads/master
6:38:09 PM: Starting build script
6:38:09 PM: Installing dependencies
6:38:09 PM: Started restoring cached node version
6:38:12 PM: Finished restoring cached node version
6:38:13 PM: v8.9.4 is already installed.
6:38:14 PM: Now using node v8.9.4 (npm v5.6.0)
6:38:14 PM: Attempting ruby version 2.3.6, read from environment
6:38:15 PM: Using ruby version 2.3.6
6:38:15 PM: Using PHP version 5.6
6:38:15 PM: Installing missing commands
6:38:15 PM: Executing user command: hugo
6:38:16 PM: Started building sites ...
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:16 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:17 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:17 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/header.html:47:110: executing "theme/partials/header.html" at <$.Site.GetPage>: can't evaluate field GetPage in type *hugolib.SiteInfo in theme/partials/header.html
6:38:17 PM: ERROR: 2018/02/19 13:08:16 template.go:132: template: theme/partials/middle.html:5:18: executing "theme/partials/middle.html" at <.Data.Term>: invalid value; expected string in theme/partials/middle.html
6:38:17 PM: Built site for language en:
6:38:17 PM: 0 draft content
6:38:17 PM: 0 future content
6:38:17 PM: 0 expired content
6:38:17 PM: 6 pages created
6:38:17 PM: 0 non-page files copied
6:38:17 PM: 0 paginator pages created
6:38:17 PM: 5 tags created
6:38:17 PM: 0 categories created
6:38:17 PM: total in 62 ms
6:38:17 PM: Caching artifacts
6:38:17 PM: Started saving pip cache
6:38:17 PM: Finished saving pip cache
6:38:17 PM: Started saving emacs cask dependencies
6:38:17 PM: Finished saving emacs cask dependencies
6:38:17 PM: Started saving maven dependencies
6:38:17 PM: Finished saving maven dependencies
6:38:17 PM: Started saving boot dependencies
6:38:17 PM: Finished saving boot dependencies
6:38:17 PM: Error running command: Build script returned non-zero exit code: 255
6:38:17 PM: Failing build: Failed to build site
6:38:17 PM: failed during stage 'building site': Build script returned non-zero exit code: 255
6:38:17 PM: Finished processing build request in 15.087382101s

How can I fix this?

What is the content of your netlify.toml file? If you have none, Netlify is using version 0.17 which might not have the features you are using.

My netlify.toml looks like this (if that helps):

[build]
  publish = "public"
  command = "hugo"

[context.production]
  command = "hugo"
  [context.production.environment]
    HUGO_VERSION = "0.36"
    HUGO_ENV = "production"

Thanks @davidsneighbour! I did not know netlify defaults to 0.17. I just imagined it will use the latest hugo version. Using a netlify.toml fixed the problem

Thanks!

Have a look at this documentation: https://www.netlify.com/docs/build-settings/