Compare commits
No commits in common. "master" and "v0.1.0" have entirely different histories.
209
README.md
209
README.md
|
@ -1,209 +0,0 @@
|
||||||
# A Basic Hugo Theme
|
|
||||||
|
|
||||||
While the official documentation about Hugo [Templates](https://gohugo.io/templates/)
|
|
||||||
does provide all of the pieces to get started creating a theme, it doesn't
|
|
||||||
necessarily put them together in one, easy-to-see-together place. This theme
|
|
||||||
attempts to pull all of the necessary pieces together into a theme that can be
|
|
||||||
used as a starting point to create more sophisticated themes.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
Follow the [Hugo Quickstart](https://gohugo.io/getting-started/quick-start/)
|
|
||||||
instructions on how to install Hugo, create a site, and install a theme.
|
|
||||||
Installing the theme as a git submodule is the preferred way.
|
|
||||||
|
|
||||||
```
|
|
||||||
git submodule add https://git.thecorams.net/kevin/basic-theme.git themes/basic-theme
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example Site
|
|
||||||
|
|
||||||
The theme includes an example site to give a quick way to see how the theme
|
|
||||||
looks and behaves.
|
|
||||||
|
|
||||||
```
|
|
||||||
cd exampleSite
|
|
||||||
hugo serve [ -D ] --themesDir ../..
|
|
||||||
```
|
|
||||||
|
|
||||||
Most of the sample posts are intentionally set `draft: true` to allow for
|
|
||||||
testing few posts vs many posts.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
As a very basic theme, there is very little to be configured via the `config.toml`
|
|
||||||
file.
|
|
||||||
|
|
||||||
The footer layout file uses Hugo's `markdownify` pipe to display the `copyright`
|
|
||||||
configuration setting, providing support both for HTML character escape
|
|
||||||
sequences such as `©` as well as markdwn formatting and links.
|
|
||||||
|
|
||||||
Note: Hugo versions 0.60.0 and up will have restrictions on using embedded HTML,
|
|
||||||
including escape secquences, unless the Goldmark renderer is configure with
|
|
||||||
`unsafe = true`.
|
|
||||||
|
|
||||||
### `subtitle` parameter
|
|
||||||
|
|
||||||
Setting the `subtitle` parameter adds a secondary header underneath the `title`
|
|
||||||
in the site header.
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[params]
|
|
||||||
subtitle = "A sub-title for your site"
|
|
||||||
```
|
|
||||||
|
|
||||||
### `mainSections` parameter
|
|
||||||
|
|
||||||
Setting the `mainSections` parameter restricts the pages that appear on the
|
|
||||||
homepage.
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[params]
|
|
||||||
mainSections = ["posts"]
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## Theme Organization
|
|
||||||
|
|
||||||
### Semantic Content Organization
|
|
||||||
|
|
||||||
The chrome of the theme page organization is as follows:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Site Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<hgroup>
|
|
||||||
<h1>Site Title</h1>
|
|
||||||
<h2>Site Sub-title</h2>
|
|
||||||
</hgroup>
|
|
||||||
<nav>
|
|
||||||
<!-- Site Navigation/Menu: links to pages that are part of -->
|
|
||||||
<!-- the "main" menu -->
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
<header>
|
|
||||||
<h1>Content Title</h1>
|
|
||||||
<nav>
|
|
||||||
<!-- Content Navigation/Menu: a place holder for a -->
|
|
||||||
<!-- content specific menu, such as a list of blog posts -->
|
|
||||||
<!-- based on publication date. Not yet implemented. -->
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
<section>
|
|
||||||
<!-- The page content. For list sections, this is where the -->
|
|
||||||
<!-- the list of pages goes. For single pages, this is where -->
|
|
||||||
<!-- the content of the page markdown file goes. -->
|
|
||||||
</section>
|
|
||||||
<footer>
|
|
||||||
<!-- The page footer. For list sections, this is where the -->
|
|
||||||
<!-- pagination controls can go. For single pages, this is -->
|
|
||||||
<!-- where auther attribution and/or prev/next page controls -->
|
|
||||||
<!-- could go. -->
|
|
||||||
</footer>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
<!-- The Site Footer, for copyright information etc. -->
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
If the content pages use `##` as their largest heading, this will result
|
|
||||||
in document outlines structured as:
|
|
||||||
|
|
||||||
1. Site Title
|
|
||||||
1. Site Sub-title
|
|
||||||
2. Content Title
|
|
||||||
1. Header from Content
|
|
||||||
1. Sub-header from content
|
|
||||||
2. Second Header from Content
|
|
||||||
|
|
||||||
### Hugo Templating
|
|
||||||
|
|
||||||
The template layout files make heavy use of Hugo's
|
|
||||||
[base and block constructs](https://gohugo.io/templates/base/), as can be seen
|
|
||||||
in [baseof.html](layouts/_default/baseof.html).
|
|
||||||
|
|
||||||
#### title
|
|
||||||
|
|
||||||
This block is used for generating the `<title>....</title>` markup for the
|
|
||||||
rendered page and defaults to using the `title` configuration from `comfig.toml`.
|
|
||||||
The [list](layouts/_default/list.html) and [single](layouts/_default/single.html)
|
|
||||||
templates add the page title, to facilitate generating a unique title for every
|
|
||||||
page.
|
|
||||||
|
|
||||||
#### site-header
|
|
||||||
|
|
||||||
This block is for providing a site banner that will appear at the top of every page,
|
|
||||||
and matches with the primary `<header>...</header>` definition from the semantic
|
|
||||||
organization, above.
|
|
||||||
|
|
||||||
The default site-header block displays the [header.html](layouts/partials/header.html)
|
|
||||||
partial.
|
|
||||||
|
|
||||||
#### site-menu
|
|
||||||
|
|
||||||
This block is for providing a site-level navigation, which also appears at the
|
|
||||||
top of every page. It renders in the `<nav>...</nav>` block within the primary
|
|
||||||
header.
|
|
||||||
|
|
||||||
The default site-meny block displays the [site-menu](layouts/partials/site-menu.html)
|
|
||||||
partial.
|
|
||||||
|
|
||||||
#### content-header
|
|
||||||
|
|
||||||
This block is for providing a header for the specific page, matching with the
|
|
||||||
header block inside the `<main>....<\main>` definition from the semantic
|
|
||||||
organization. The [list](layouts/_default/list.html) and
|
|
||||||
[single](layouts/_default/single.html) templates display the page title as
|
|
||||||
a `<h1>...</h1>` level header.
|
|
||||||
|
|
||||||
#### content-menu
|
|
||||||
|
|
||||||
This block is for providing navigation menu(s) for the main content, matching
|
|
||||||
with the `<nav>...</nav>` block inside the main header. The block is currently
|
|
||||||
a place holder, with no default implementation.
|
|
||||||
|
|
||||||
#### content
|
|
||||||
|
|
||||||
This block is for the content of the page.
|
|
||||||
|
|
||||||
For [list](layouts/_default/list.html) pages, the content from the section's
|
|
||||||
`_index.md` will be rendered, followed by a list of all of the pages within
|
|
||||||
the section, using the [summary](layouts/_default/summary.html) template.
|
|
||||||
|
|
||||||
For [single](layouts/_default/single.html) pages, the page content will be
|
|
||||||
rendered inside an `<article>...</article>` block element.
|
|
||||||
|
|
||||||
#### content-footer
|
|
||||||
|
|
||||||
This block provides a footer for the page, which renders within the
|
|
||||||
`<footer></footer>` block at the end of the `<main></main>` section.
|
|
||||||
|
|
||||||
The default content-footer blocks for the homepage and for list pages
|
|
||||||
implement pagination controls to show the content summaries a page at a time.
|
|
||||||
|
|
||||||
The default content-footer block for single pages displays previous and/or
|
|
||||||
next in section links.
|
|
||||||
|
|
||||||
#### footer
|
|
||||||
|
|
||||||
This block is for the site footer that appears at the end of every pages.
|
|
||||||
|
|
||||||
The default footer block displays the [footer.html](layouts/partials/footer.html)
|
|
||||||
partial.
|
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
### HTML5 Semantics
|
|
||||||
|
|
||||||
- [Semantic HTML](https://internetingishard.com/html-and-css/semantic-html/)
|
|
||||||
- [HTML5 Semantic Elements](https://guide.freecodecamp.org/html/html5-semantic-elements/)
|
|
||||||
- [A Look Into Proper HTML5 Semantics](https://www.hongkiat.com/blog/html-5-semantics/amp/)
|
|
||||||
- [HTML5 Semantic Tags: What Are They & How To Use Them! - SEMrush](https://www.semrush.com/blog/semantic-html5-guide/)
|
|
||||||
|
|
|
@ -3,11 +3,10 @@ languageCode = "en-us"
|
||||||
title = "Basic Hugo Theme"
|
title = "Basic Hugo Theme"
|
||||||
copyright = "Copyright © 2019, Copyright Owner Name | Built with [Hugo](https://gohugo.io/)"
|
copyright = "Copyright © 2019, Copyright Owner Name | Built with [Hugo](https://gohugo.io/)"
|
||||||
theme = "basic-theme"
|
theme = "basic-theme"
|
||||||
paginate = 5
|
paginate = 10
|
||||||
|
|
||||||
[permalinks]
|
[permalinks]
|
||||||
posts = "/:year/:month/:title/"
|
posts = "/:year/:month/:title/"
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
subtitle = "A theme with no CSS and only basic layouts"
|
subtitle = "A theme with no CSS and only basic layouts"
|
||||||
mainSections = [ "posts" ]
|
|
||||||
|
|
|
@ -4,48 +4,22 @@
|
||||||
<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>
|
<!-- Code that all your templates share, like a header -->
|
||||||
{{- block "site-header" . -}}
|
{{ partial "header.html" . }}
|
||||||
<!-- Code that all your templates share, like a header -->
|
{{ block "main" . }}
|
||||||
{{ partial "header.html" . }}
|
<!-- The part of the page that begins to differ between templates -->
|
||||||
{{- end }}
|
{{ end }}
|
||||||
<nav>
|
{{ block "footer" . }}
|
||||||
{{ block "site-menu" . -}}
|
<!-- More shared code, perhaps a footer but that can be overridden if need be in -->
|
||||||
{{ partial "site-menu.html" . }}
|
{{ partial "footer.html" . }}
|
||||||
{{- end }}
|
{{ 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 -->
|
|
||||||
{{ end }}
|
|
||||||
</section>
|
|
||||||
<footer>
|
|
||||||
{{- block "content-footer" . -}}
|
|
||||||
{{- end -}}
|
|
||||||
</footer>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
{{- block "footer" . -}}
|
|
||||||
<!-- More shared code, perhaps a footer but that can be overridden if need be in -->
|
|
||||||
{{- partial "footer.html" . -}}
|
|
||||||
{{- end -}}
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -2,19 +2,18 @@
|
||||||
{{ define "title" }}
|
{{ define "title" }}
|
||||||
{{ .Title }} – {{ .Site.Title }}
|
{{ .Title }} – {{ .Site.Title }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ define "content-header" }}
|
{{ define "main" }}
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<main>
|
||||||
{{ end }}
|
<div>
|
||||||
{{ define "content" }}
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
<header class="list-content">
|
<div class="list-content">
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</header>
|
</div>
|
||||||
{{ range $index, $page := (.Paginate (where .Pages ".Params.hidden" "!=" "true")).Pages }}
|
<div class="list-summary">
|
||||||
{{ if ne $index 0 }}
|
{{ range .Pages }}
|
||||||
{{ end }}
|
{{ .Render "summary"}}
|
||||||
{{ .Render "summary" }}
|
{{ end }}
|
||||||
{{ end }}
|
</div>
|
||||||
{{ end }}
|
</div>
|
||||||
{{ define "content-footer" }}
|
</main>
|
||||||
{{ partial "paginator.html" .Paginator }}
|
|
||||||
{{ end }}
|
{{ end }}
|
|
@ -2,14 +2,9 @@
|
||||||
{{ define "title" }}
|
{{ define "title" }}
|
||||||
{{ .Title }} – {{ .Site.Title }}
|
{{ .Title }} – {{ .Site.Title }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ define "content-header" }}
|
{{ define "main" }}
|
||||||
<h1>{{ .Title }}</h1>
|
<main>
|
||||||
{{ end }}
|
<h1>{{ .Title }}</h1>
|
||||||
{{ define "content" }}
|
|
||||||
<article>
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</article>
|
</main>
|
||||||
{{ end }}
|
|
||||||
{{ define "content-footer" }}
|
|
||||||
{{ partial "prev-next-page.html" . }}
|
|
||||||
{{ end }}
|
{{ end }}
|
|
@ -3,14 +3,12 @@
|
||||||
<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>
|
|
@ -1,15 +1,22 @@
|
||||||
{{ define "content" }}
|
{{ define "main" }}
|
||||||
<article class="homepage-content">
|
<main>
|
||||||
<!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md -->
|
<header class="homepage-header">
|
||||||
{{.Content}}
|
<h1>{{.Title}}</h1>
|
||||||
</article>
|
{{ if .Params.Subtitle }}
|
||||||
<!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
|
<span class="subtitle">{{.Params.Subtitle}}</span>
|
||||||
{{ range $index, $page := (.Paginate (where (where .Site.RegularPages "Type" "in" site.Params.mainSections) ".Params.hidden" "!=" "true" )).Pages }}
|
{{ else if .Site.Params.Subtitle }}
|
||||||
{{ if ne $index 0 }}
|
<span class="subtitle">{{.Site.Params.Subtitle}}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ .Render "summary" }}
|
</header>
|
||||||
{{ end }}
|
<div class="homepage-content">
|
||||||
{{ end }}
|
<!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md -->
|
||||||
{{ define "content-footer" }}
|
{{.Content}}
|
||||||
{{ partial "paginator.html" .Paginator }}
|
</div>
|
||||||
|
<div>
|
||||||
|
<!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
|
||||||
|
{{ range first 10 .Pages }}
|
||||||
|
{{ .Render "summary"}}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
|
@ -1,3 +1,5 @@
|
||||||
{{ with .Site.Copyright }}
|
<footer>
|
||||||
<p class="copyright">{{ . | markdownify }}</p>
|
{{ with .Site.Copyright }}
|
||||||
{{ end }}
|
<p class="copyright">{{ . | markdownify }}</p>
|
||||||
|
{{ end }}
|
||||||
|
</footer>
|
|
@ -1,6 +1,31 @@
|
||||||
<hgroup>
|
<header>
|
||||||
<h1>{{.Site.Title}}</h1>
|
<nav>
|
||||||
{{- if .Site.Params.Subtitle }}
|
<ul>
|
||||||
<h2 class="subtitle">{{.Site.Params.Subtitle}}</h2>
|
{{ $currentPage := . }}
|
||||||
{{- end }}
|
{{ range .Site.Menus.main }}
|
||||||
</hgroup>
|
{{ 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>
|
|
@ -1,19 +0,0 @@
|
||||||
<nav>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
{{if .HasPrev}}
|
|
||||||
<a alt="Newer articles" href="{{ .Prev.URL }}">← Newer</a>
|
|
||||||
{{ else }}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
</li>
|
|
||||||
<li>Page {{ .PageNumber }} of {{ .TotalPages }}</li>
|
|
||||||
<li>
|
|
||||||
{{if .HasNext}}
|
|
||||||
<a alt="Older articles" href="{{ .Next.URL }}">Older →</a>
|
|
||||||
{{ else }}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
|
@ -1,20 +0,0 @@
|
||||||
{{ if not .Params.Menu }}
|
|
||||||
<nav>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
{{ if .NextInSection }}
|
|
||||||
<a alt="Newer article" href="{{ .NextInSection.Permalink }}">← Newer</a>
|
|
||||||
{{ else }}
|
|
||||||
|
|
||||||
{{ end }} </li>
|
|
||||||
<li><a alt="Top of page" href="#">Top</a></li>
|
|
||||||
<li>
|
|
||||||
{{ if .PrevInSection }}
|
|
||||||
<a alt="Older article" href="{{ .PrevInSection.Permalink }}">Older →</a>
|
|
||||||
{{ else }}
|
|
||||||
|
|
||||||
{{ end }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{ end }}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<ul>
|
|
||||||
{{ if not .IsHome }}
|
|
||||||
<li><a href="{{ .Site.BaseURL }}">Home</a></li>
|
|
||||||
{{ end }}
|
|
||||||
{{- $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>
|
|
Loading…
Reference in New Issue