Panic: template: home:6: function "StaticUrlPrefix" not defined

I am trying to customize the homepage (custom/templates/home.tmpl) and the following error is occurring:

git@ip-172-26-5-60:~$ GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
2019/11/09 12:12:39 ...dules/setting/git.go:83:newGit() [I] Git Version: 2.17.1
2019/11/09 12:12:39 routers/init.go:72:GlobalInit() [T] AppPath: /usr/local/bin/gitea
2019/11/09 12:12:39 routers/init.go:73:GlobalInit() [T] AppWorkPath: /var/lib/gitea/
2019/11/09 12:12:39 routers/init.go:74:GlobalInit() [T] Custom path: /var/lib/gitea/custom
2019/11/09 12:12:39 routers/init.go:75:GlobalInit() [T] Log path: /var/lib/gitea/log
2019/11/09 12:12:39 ...dules/setting/log.go:226:newLogService() [I] Gitea v1.9.5 built with GNU Make 4.1, go1.12.11 : bindata, sqlite, sqlite_unlock_notify
panic: template: home:6: function "StaticUrlPrefix" not defined

goroutine 1 [running]:
html/template.Must(...)
	/usr/local/go/src/html/template/template.go:372
code.gitea.io/gitea/vendor/gopkg.in/macaron%2ev1.compile(0x1bf2b4f, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00077e660, 0x2, 0x2, ...)
	/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/render.go:292 +0x4ed
code.gitea.io/gitea/vendor/gopkg.in/macaron%2ev1.(*TemplateSet).Set(0xc0015d9c50, 0x1bebe67, 0x7, 0xc00077c1e0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/render.go:318 +0x84
code.gitea.io/gitea/vendor/gopkg.in/macaron%2ev1.renderHandler(0x1bf2b4f, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00077e660, 0x2, 0x2, ...)
	/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/render.go:385 +0x125
code.gitea.io/gitea/vendor/gopkg.in/macaron%2ev1.Renderer(0xc0026acf30, 0x1, 0x1, 0xc00077e620, 0xc00177e000)
	/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/render.go:422 +0x11e
code.gitea.io/gitea/modules/templates.HTMLRenderer(0x1971b60, 0xc00174e100)
	/go/src/code.gitea.io/gitea/modules/templates/static.go:117 +0x155
code.gitea.io/gitea/routers/routes.NewMacaron(0xc00003ef20)
	/go/src/code.gitea.io/gitea/routers/routes/routes.go:165 +0x5b0
code.gitea.io/gitea/cmd.runWeb(0xc00003ef20, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/cmd/web.go:110 +0x78
code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0x19715c0, 0x29dcc60, 0xc00003ef20, 0xc00081a300, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:490 +0xc8
code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(0x1be63ff, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c13c35, 0x16, 0x0, ...)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:210 +0x996
code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0xc0000a4ea0, 0xc00003c0c0, 0x4, 0x4, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:255 +0x6af
main.main()
	/go/src/code.gitea.io/gitea/main.go:109 +0x811

How can I fix this?

Please compare changes in home.tmpl in gitea source code. There was recently changes related to that

1 Like

I was using the 1.9.5 binary and the latest release template. I put the template from version 1.9.5 and now it’s working. Problem solved.

Thanks!