Hugo go go go

Made a hugo setup from scratch to generate a static blog and portfolio webpage.
The old stuff may still be found in static/old.
This commit is contained in:
2022-03-29 22:52:36 +00:00
parent 1e418219e9
commit d64efb5fb4
60 changed files with 658 additions and 33 deletions

View File

@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name=”robots” content="index,follow">
{{ block "meta" . }}
<meta name="viewport" content="width=device-width,initial-scale=1.0">
{{ end }}
<meta name="twitter:card" content="summary">
<meta property="og:title" content="{{ site.Title }}" />
<meta property="og:url" content="{{ site.BaseURL }}" />
<meta property="og:site_name" content="{{ site.Title }}" />
<!-- <meta property="og:image" content=""> -->
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/css/bootstrap.min.css' crossorigin='anonymous'>
{{ if isset .Params "title" }}
<title>{{ site.Title }} - {{ .Title }}</title>
{{ else }}
<title>{{ site.Title }}</title>
{{ end }}{{ if .Description }}
<meta name='description' content='{{ .Description }}'>
{{ end }}
{{ block "head" . }}
<link href='/main.css' rel='stylesheet'>
{{ end }}
</head>
<body>
<header>
{{ partial "nav.html" . }}
</header>
<div id="content">
<main>{{ block "main" . }}{{ end }}</main>
</div>
<!-- {{ partial "i18n/list.html" . }} -->
<footer>
{{ partial "footer.html" . }}
</footer>
</body>
{{ block "bottom" . }}{{ end }}
</html>

View File

@@ -0,0 +1,10 @@
{{ define "main" }}
{{ .Content }}
<ul class='contents'>
{{ range .Pages }}
<li>
<a href='{{ .Permalink }}'>{{ .Date.Format "2006/01/02" }} - {{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}

View File

@@ -0,0 +1,24 @@
{{ define "main" }}
<div class='row'>
<div class='col-md-2'>
<aside id="meta">
{{ .TableOfContents }}
</aside>
</div>
<div class='col-md-10'>
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
<ul class="contents">
{{ range .Pages }}
<li>
{{ partial "summary.html" . }}
</li>
{{ end }}
</ul>
</article>
</div>
</div>
{{ end }}

38
layouts/_default/rss.xml Normal file
View File

@@ -0,0 +1,38 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description>
</item>{{ end }}
</channel>
</rss>

View File

@@ -0,0 +1,15 @@
{{ define "main" }}
<div class='row'>
<div class='col-md-2'>
{{ partial "toc.html" . }}
</div>
<div class='col-md-10'>
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
</article>
</div>
</div>
{{ end }}

21
layouts/blog/single.html Normal file
View File

@@ -0,0 +1,21 @@
{{ define "main" }}
<div class='row'>
<div class='col-md-2'>
<aside id="meta">
{{ if .IsPage }}
{{ partial "breadcrumb.html" . }}
<p>{{ i18n "readingTime" .ReadingTime }}</p>
{{ end }}
{{ .TableOfContents }}
</aside>
</div>
<div class='col-md-10'>
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
</article>
</div>
</div>
{{ end }}

17
layouts/index.html Normal file
View File

@@ -0,0 +1,17 @@
{{ define "main" }}
<div class='row'>
<div class='col-md-2'>
<aside id="meta">
{{ .TableOfContents }}
</aside>
</div>
<div class='col-md-10'>
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
</article>
</div>
</div>
{{ end }}

View File

@@ -0,0 +1,13 @@
<ol class="nav navbar-nav">
{{ template "breadcrumbnav" (dict "p1" . "p2" .) }}
</ol>
{{ define "breadcrumbnav" }}
{{ if .p1.Parent }}
{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 ) }}
{{ else if not .p1.IsHome }}
{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) }}
{{ end }}
<li{{ if eq .p1 .p2 }} class="active"{{ end }}>
<a href="{{ .p1.Permalink }}">{{ .p1.Title }}</a>
</li>
{{ end }}

View File

@@ -0,0 +1,13 @@
<center>
<div class='footer-content'>
<p>{{ now.Format "2006" }} &copy; Sivert V. Sæther</p>
</div>
<div class='footer-social'>
<!--
<a href="#" class="icons"><img src="/facebook-icon.svg"></a>
<a href="#" class="icons"><img src="/linkedin-icon.svg"></a>
<a href="#" class="icons"><img src="/twitter-icon.svg"></a>
<a href="#" class="icons"><img src="/youtube-icon.svg"></a>
-->
</div>
</center>

View File

@@ -0,0 +1,6 @@
{{ if .IsTranslated }}<h4>{{ T "translations" }}</h4>
<ul>{{ range .Translations }}
<li>
<a href='{{ .Permalink }}'>{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
</li>{{ end }}
</ul>{{ end }}

View File

@@ -0,0 +1,8 @@
<li id='lang-menu'>
<a id='lang-menu-btn' href='#'>{{ T "translations" }}</a>
<ul>
{{ range $.Site.Home.AllTranslations }}
<li><a href='{{ .Permalink }}'>{{ .Language.LanguageName }}</a></li>
{{ end }}
</ul>
</li>

34
layouts/partials/nav.html Normal file
View File

@@ -0,0 +1,34 @@
<nav id="navbar">
<ul class="top-nav">
<li class=""><a href="/">{{ site.Title }}</a></li>
{{ partial "i18n/nav.html" . }}
<div class="link-group">
{{ $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 }}
<!-- <li class="top-nav__link"><a href="#">
<img class="icons" src="/search-icon.svg">
</a>
</li> -->
</div>
</ul>
</nav>

View File

@@ -0,0 +1,11 @@
<article>
<div>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ .Summary }}
</div>
{{ if .Truncated }}
<div>
<a href="{{ .RelPermalink }}">{{ i18n "readMore" }}…</a>
</div>
{{ end }}
</article>

View File

@@ -0,0 +1,6 @@
<aside id='meta'>
<header>
<h4>{{ .Title }}</h4>
</header>
{{ .TableOfContents }}
</aside>

2
layouts/robots.txt Normal file
View File

@@ -0,0 +1,2 @@
User-agent: *{{ range .Site.AllPages }}
Allow: {{ .RelPermalink }}{{ end }}