Content-Length: 216369 | pFad | http://github.com/gogs/gogs/issues/7951

C9 Gogs crashes after copying home.tmpl into custom/templates/ · Issue #7951 · gogs/gogs · GitHub
Skip to content

Gogs crashes after copying home.tmpl into custom/templates/ #7951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
deadtom76 opened this issue Apr 7, 2025 · 1 comment
Open
1 task done

Gogs crashes after copying home.tmpl into custom/templates/ #7951

deadtom76 opened this issue Apr 7, 2025 · 1 comment
Labels
💊 bug Something isn't working

Comments

@deadtom76
Copy link

Gogs version

0.13.2

Git version

  • Server: 2.39.5
  • Client: 2.39.5

Operating system

Debian 12

Database

SQLite 3

Describe the bug

When I copy home.tmpl into custom/templates/, and then restart Gogs, it produces the following error:

`panic: template: home:1351: function "className" not defined

goroutine 1 [running]:
html/template.Must(...)
html/template/template.go:368
gopkg.in/macaron%2ev1.compile({{0xc00004ecc0, 0x18}, {0xc0009067e0, 0x1, 0x1}, {0x0, 0x0}, {0xc0003e8ae0, 0x2, 0x2}, ...})
gopkg.in/macaron.v1@v1.4.0/render.go:291 +0x3c5
gopkg.in/macaron%2ev1.(*TemplateSet).Set(0xc00067b110, {0x15bd3d4, 0x7}, 0xc00083c000)
gopkg.in/macaron.v1@v1.4.0/render.go:317 +0x9e
gopkg.in/macaron%2ev1.renderHandler({{0xc00004ecc0, 0x18}, {0xc0009067e0, 0x1, 0x1}, {0x0, 0x0}, {0xc0003e8ae0, 0x2, 0x2}, ...}, ...)
gopkg.in/macaron.v1@v1.4.0/render.go:384 +0x158
gopkg.in/macaron%2ev1.Renderer({0xc00098f258?, 0xc000712280?, 0xc000046420?})
gopkg.in/macaron.v1@v1.4.0/render.go:421 +0x14f
gogs.io/gogs/internal/cmd.newMacaron()
gogs.io/gogs/internal/cmd/web.go:124 +0xb6c
gogs.io/gogs/internal/cmd.runWeb(0xc000572b00)
gogs.io/gogs/internal/cmd/web.go:171 +0xaa
github.com/urfave/cli.HandleAction({0x13b0f80?, 0x2766748?}, 0x3?)
github.com/urfave/cli@v1.22.16/app.go:524 +0x50
github.com/urfave/cli.Command.Run({{0x15b6811, 0x3}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x15d100c, 0x10}, {0x0, ...}, ...}, ...)
github.com/urfave/cli@v1.22.16/command.go:175 +0x67c
github.com/urfave/cli.(*App).Run(0xc000485340, {0xc00011c870, 0x3, 0x3})
github.com/urfave/cli@v1.22.16/app.go:277 +0xb3b
main.main()
gogs.io/gogs/gogs.go:39 +0x3ec`

I have not yet made any changes to home.tmpl.

To reproduce

  1. Stop Gogs.
  2. Download home.tmpl from https://github.com/gogs/gogs/blob/main/templates/home.tmpl.
  3. Place home.tmpl in gogs/custom/templates/.
  4. Start Gogs.

Expected behavior

Should start without issue.

Additional context

I want to personalize the landing page for our organization. The instructions at https://gogs.io/docs/features/custom_template say to copy the content of template file "templates/home.tmpl" to "custom/templates/home.tmpl", but there is no "templates/home.tmpl". So I'm downloading it from github instead.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@deadtom76 deadtom76 added the 💊 bug Something isn't working label Apr 7, 2025
@Xzavir420
Copy link

The error you're experiencing indicates that the copied home.tmpl template uses a function className that is not defined in your Gogs setup. This could be due to differences between the version of the Gogs you're running (0.13.2) and the latest version of the home.tmpl template from the repository.

Possible Fixes:

  1. Use the Correct Version of home.tmpl:

    • The home.tmpl you downloaded from https://github.com/gogs/gogs/blob/main/templates/home.tmpl may not be compatible with your Gogs version (0.13.2).
    • Instead, download the home.tmpl template that corresponds to your version (0.13.2). For example:
      wget https://raw.githubusercontent.com/gogs/gogs/v0.13.2/templates/home.tmpl -O custom/templates/home.tmpl
  2. Check for Missing Function Definitions:

    • The className function might not be defined in your version of Gogs. This could be:
      • A helper function missing from your version's template rendering setup.
      • A function introduced in a later version of Gogs.
  3. Inspect the Gogs Documentation:

    • Double-check the documentation for Gogs v0.13.2 to ensure the instructions for customizing templates are accurate for your version.
  4. Debug the Template:

    • Temporarily remove or comment out the part of the template that uses the className function to see if Gogs starts without errors:
      {{/* Comment out or modify problematic template lines */}}
  5. Upgrade Gogs (Optional):

    • If you want to use the latest home.tmpl and its features, consider upgrading Gogs to the latest version. However, upgrading might require additional testing and adjustments, especially for database migrations.
  6. Custom Implementation:

    • If the className function is essential, you could try implementing it in your version of Gogs by extending the template engine. However, this requires familiarity with Go and the Gogs codebase.

Let me know if you'd like detailed instructions for any of these steps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💊 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/gogs/gogs/issues/7951

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy