Move majority of semantic tags to baseof.html

In order to improve the semantic layout of the page(s) in the site, the
bulk of the semantic elements have been explicitly moved to the baseof
file. Additional Hugo blocks have been defined to allow layouts to
supply or override things like section menus, the site menu, etc.
pull/1/head
Kevin C. Coram 2019-11-20 23:38:53 -05:00
parent a862ddf302
commit 321fe23ea8
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
8 changed files with 105 additions and 91 deletions

View File

@ -4,22 +4,44 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ block "title" . }} <title>{{- block "title" . -}}
{{ .Site.Title }} {{ .Site.Title }}
{{ end }}</title> {{- end -}}</title>
</head> </head>
<body> <body>
<header>
{{- block "site-header" . -}}
<!-- Code that all your templates share, like a header --> <!-- Code that all your templates share, like a header -->
{{ partial "header.html" . }} {{ partial "header.html" . }}
{{ block "main" . }} {{- end }}
<nav>
{{ block "site-menu" . -}}
{{ partial "site-menu.html" . }}
{{- end }}
</nav>
</header>
<main>
<header>
{{- block "content-header" . -}}
{{- end -}}
<nav>
{{- block "content-menu" . -}}
{{- end -}}
</nav>
</header>
<section>
{{- block "content" . -}}
<!-- The part of the page that begins to differ between templates --> <!-- The part of the page that begins to differ between templates -->
{{ end }} {{ end }}
{{ block "footer" . }} </section>
</main>
<footer>
{{- block "footer" . -}}
<!-- More shared code, perhaps a footer but that can be overridden if need be in --> <!-- More shared code, perhaps a footer but that can be overridden if need be in -->
{{ partial "footer.html" . }} {{- partial "footer.html" . -}}
{{ end }} {{- end -}}
</footer>
</body> </body>
</html> </html>

View File

@ -2,18 +2,14 @@
{{ define "title" }} {{ define "title" }}
{{ .Title }} &ndash; {{ .Site.Title }} {{ .Title }} &ndash; {{ .Site.Title }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "content-header" }}
<main>
<div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
<div class="list-content"> {{ end }}
{{ define "content" }}
<header class="list-content">
{{ .Content }} {{ .Content }}
</div> </header>
<div class="list-summary">
{{ range .Pages }} {{ range .Pages }}
{{ .Render "summary"}} {{ .Render "summary"}}
{{ end }} {{ end }}
</div>
</div>
</main>
{{ end }} {{ end }}

View File

@ -2,9 +2,11 @@
{{ define "title" }} {{ define "title" }}
{{ .Title }} &ndash; {{ .Site.Title }} {{ .Title }} &ndash; {{ .Site.Title }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "content-header" }}
<main>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{ .Content }} {{ end }}
</main> {{ define "content" }}
<article>
{{ .Content }}
</article>
{{ end }} {{ end }}

View File

@ -3,12 +3,14 @@
<h2><a href='{{ .Permalink }}'>{{ .Title }}</a> </h2> <h2><a href='{{ .Permalink }}'>{{ .Title }}</a> </h2>
<div class="post-meta">{{ .Date.Format "Mon, Jan 2, 2006" }} - {{ .FuzzyWordCount }} Words </div> <div class="post-meta">{{ .Date.Format "Mon, Jan 2, 2006" }} - {{ .FuzzyWordCount }} Words </div>
</header> </header>
<section>
{{ .Summary }} {{ .Summary }}
{{ if .Truncated }} </section>
{{- if .Truncated }}
<footer> <footer>
<a href='{{ .Permalink }}'> <a href='{{ .Permalink }}'>
<span style="white-space: nowrap;">Read more →</span> <span style="white-space: nowrap;">Read more →</span>
</a> </a>
</footer> </footer>
{{ end }} {{- end }}
</article> </article>

View File

@ -1,22 +1,20 @@
{{ define "main" }} {{- define "content-header" -}}
<main> <hgroup>
<header class="homepage-header">
<h1>{{.Title}}</h1> <h1>{{.Title}}</h1>
{{ if .Params.Subtitle }} {{- if .Params.Subtitle }}
<span class="subtitle">{{.Params.Subtitle}}</span> <h2 class="subtitle">{{.Params.Subtitle}}</h2>
{{ else if .Site.Params.Subtitle }} {{- else if .Site.Params.Subtitle }}
<span class="subtitle">{{.Site.Params.Subtitle}}</span> <h2 class="subtitle">{{.Site.Params.Subtitle}}</h2>
{{- end }}
</hgroup>
{{ end }} {{ end }}
</header> {{ define "content" }}
<div class="homepage-content"> <article class="homepage-content">
<!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md --> <!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md -->
{{.Content}} {{.Content}}
</div> </article>
<div>
<!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. --> <!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
{{ range first 10 .Pages }} {{ range first 10 .Pages }}
{{ .Render "summary"}} {{ .Render "summary"}}
{{ end }} {{ end }}
</div>
</main>
{{ end }} {{ end }}

View File

@ -1,5 +1,3 @@
<footer>
{{ with .Site.Copyright }} {{ with .Site.Copyright }}
<p class="copyright">{{ . | markdownify }}</p> <p class="copyright">{{ . | markdownify }}</p>
{{ end }} {{ end }}
</footer>

View File

@ -1,31 +0,0 @@
<header>
<nav>
<ul>
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<a href="#">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
<ul class="sub-menu">
{{ range .Children }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ else }}
<li>
<a href="{{ .URL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
{{ end }}
{{ end }}
</ul>
</nav>
</header>

View File

@ -0,0 +1,27 @@
<ul>
{{- $currentPage := . -}}
{{- range .Site.Menus.main -}}
{{- if .HasChildren -}}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<a href="#">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
<ul class="sub-menu">
{{ range .Children }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ else }}
<li>
<a href="{{ .URL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
{{- end -}}
{{ end }}
</ul>