I'm trying to create a layout for my website where I use partials for my header and footer.
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{title}}</title>
<script src="https://unpkg.com/[email protected]" crossorigin="anonymous"></script>
<link href='/static/css/global.css' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Rubik' rel='stylesheet'>
</head>
<body>
{{> views/partials/header }}
{{{embed}}}
{{> views/partials/footer }}
</body>
</html>
I followed the example as shown here: https://docs.gofiber.io/template/mustache/
The embedding works fine, but the partials won't work.
My file structure is like this:
views
├── layout.mu
└── partials
├── header.mu
└── footer.mu
Here is how I setup the app and route:
engine := mustache.New("./views", ".mu")
app := fiber.New(fiber.Config{Views: engine})
app.Get("/", func(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{
"title": "index",
}, "layout")
})
And finally here is my header:
<nav class="navigation">
<a href="/"><img alt="" class="logo" src="/static/images/logo.png"/></a>
<ul class="items">
<li>
<a class="links" href="/product">Produkt</a>
</li>
<li>
<a class="links" href="/blog">Blogg</a>
</li>
<li>
<a class="links" href="/about">Om Oss</a>
</li>
<li>
<a class="links contact" href="/contact">Kontakta Oss</a>
</li>
</ul>
</nav>