Closed jsgv closed 9 years ago
I am setting my static folder to assets, but martini is giving me a 404 error
assets
[martini] Started GET /assets/css/main.css for [::1]:52990 [martini] Completed 404 Not Found in 325.927µs
directory structure
assets/ | |__ css/ |__ main.css templates/ | |__index.tmpl |__layout.tmpl main.go
main.go
package main import ( "github.com/go-martini/martini" "github.com/martini-contrib/render" ) func main() { m := martini.Classic() m.Use(render.Renderer(render.Options{ Layout: "layout", })) m.Use(martini.Static("assets")) m.Get("/", func(r render.Render) { r.HTML(200, "index", nil) }) m.Run() }
layout.tmpl
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <link rel="stylesheet" href="assets/css/main.css"> </head> <body> {{yield}} </body> </html>
Figured out my error
I needed to remove assets from html file since I am already declaring the static folder in the go file
<link rel="stylesheet" href="css/main.css">
I am setting my static folder to
assets
, but martini is giving me a 404 errordirectory structure
main.go
layout.tmpl