How to make bootstrap style reflect on golang template

i have been having major issues making bootstrap style reflect on my html/template output and i’m wondering if there’s any other way to go about this. my code below
INDEX.HTML

    {{define "head"}}<title>Dead Or Injured</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap -->
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    {{end}}

    {{define "body"}}
    <form action="/game/submit" method="post" role="form">
    <div class="form-group">
    <p>Input your guess: <input type="text" name="guess"/></p>
    <button type="submit" value="submit" class="btn btn-default">Submit</button>
    </div>
    </form>


    <fieldset>
    {{range .}}
    <p>
    {{.}}
    </p>
    {{end}}
    </fieldset>

    {{end}}

And this is BASE.HTML

    {{define "base"}}
    <html>
    <head>{{template "head" .}}</head>
    <body>{{template "body" .}}</body>
    </html>
    {{end}}

index.html and base.html are in the same folder so i don’t think the folder structure is a problem except you think otherwise.
Here’s main.go
func main() {
mongo.GetSession()

    r := mux.NewRouter().StrictSlash(false)
    fs := http.FileServer(http.Dir("public"))
    r.Handle("/public/", fs)
    r.HandleFunc("/", gamePage)
    r.HandleFunc("/game/submit", functions.Submit)
    r.HandleFunc("/game/highscoreinput", scoreInputPage)
    r.HandleFunc("/game/postUser", mongo.PostUser)
    r.HandleFunc("/game/highscores", mongo.RetrieveUsers)

    server := &http.Server{
	    Addr:    ":8080",
	    Handler: r,
    }
    log.Println("Listening...")
    server.ListenAndServe()
    }

After all these, the template works fine and all the pnly bit remaining is for it to shake off the boring interface and make use of the bootstrap provided. Thanks.

Is /bootstrap/css/bootstrap.min.css being loaded properly from public/bootstrap/css/? Check your browser’s debug tools and console.

Also, you don’t appear to be putting the proper wrapper classes around your content, e.g. <div class="container">

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.