Hugo Static Page Like About Page

September 10, 2017

Create static about page

Create a about page.

hugo new

Edit the page’s configuration to give it a static type.

title: "About"
date: 2017-07-29T19:57:50+08:00
type: static

My about page.

Create a layout template for static type at layouts/static/single.html.

{{ define "main" }}
          {{ .Title }}

      {{ .Content }}
{{ end }}

Add about page to menu

Edit config.toml to add about page menu configuration.

    name = "About"
    weight = 1
    url = "/about/"
    identifier = "about"

Make sure your layouts/_default/baseof.html is including some partials templates (layouts/partials/*) which render the menu.

Below is a sample menu rendering template which utilize Bootstrap 4 classes.

{{ if .Site.Menus.main }}
<ul class="navbar-nav">
  {{ range .Site.Menus.main }}
  <li class="nav-item {{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
      <a class="nav-link" href="{{ .URL }}">
        {{ .Name }}
  <li class="nav-item"> 
  {{ end }}
{{ end }}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.