Browse Source

Template limpio de hugo

master
sindominio 2 years ago
commit
d619716e7a
  1. 5
      README.md
  2. 0
      archetypes/.gitkeep
  3. 6
      archetypes/default.md
  4. 16
      config
  5. 50
      config.toml
  6. 0
      content/.gitkeep
  7. 29
      content/about.md
  8. 11
      content/post/hola_mundo.md
  9. 0
      data/.gitkeep
  10. 0
      layouts/.gitkeep
  11. 0
      static/.gitkeep
  12. 0
      themes/.gitkeep
  13. 20
      themes/minimal-bootstrap-hugo-theme/LICENSE
  14. 168
      themes/minimal-bootstrap-hugo-theme/README.md
  15. 5
      themes/minimal-bootstrap-hugo-theme/archetypes/default.md
  16. 8
      themes/minimal-bootstrap-hugo-theme/archetypes/post.md
  17. 17
      themes/minimal-bootstrap-hugo-theme/dev-notes.md
  18. 49
      themes/minimal-bootstrap-hugo-theme/exampleSite/config.toml
  19. 28
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/about.md
  20. 1146
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/creating-a-new-theme.md
  21. 335
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/goisforlovers.md
  22. 81
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/hugoisforlovers.md
  23. 154
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/migrate-from-jekyll.md
  24. 98
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/script-to-add-a-page-level-variable-to-content-front-matter-in-hugo.md
  25. 88
      themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/use-snap-to-install-the-hugo-edge-version-on-fedora-and-ubuntu.md
  26. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/android-chrome-192x192.png
  27. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/android-chrome-256x256.png
  28. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/apple-touch-icon.png
  29. 9
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/browserconfig.xml
  30. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon-16x16.png
  31. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon-32x32.png
  32. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon.ico
  33. BIN
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/mstile-150x150.png
  34. 46
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/safari-pinned-tab.svg
  35. 19
      themes/minimal-bootstrap-hugo-theme/exampleSite/static/site.webmanifest
  36. 256
      themes/minimal-bootstrap-hugo-theme/gh-md-toc
  37. BIN
      themes/minimal-bootstrap-hugo-theme/images/screenshot.png
  38. BIN
      themes/minimal-bootstrap-hugo-theme/images/tn.png
  39. 20
      themes/minimal-bootstrap-hugo-theme/layouts/_default/baseof.html
  40. 0
      themes/minimal-bootstrap-hugo-theme/layouts/_default/list.html
  41. 6
      themes/minimal-bootstrap-hugo-theme/layouts/_default/single.html
  42. 13
      themes/minimal-bootstrap-hugo-theme/layouts/index.html
  43. 6
      themes/minimal-bootstrap-hugo-theme/layouts/partials/bootstrap-js.html
  44. 18
      themes/minimal-bootstrap-hugo-theme/layouts/partials/cookie-consent.html
  45. 10
      themes/minimal-bootstrap-hugo-theme/layouts/partials/google-analytics-async.html
  46. 13
      themes/minimal-bootstrap-hugo-theme/layouts/partials/google-analytics.html
  47. 46
      themes/minimal-bootstrap-hugo-theme/layouts/partials/head.html
  48. 7
      themes/minimal-bootstrap-hugo-theme/layouts/partials/nav.html
  49. 14
      themes/minimal-bootstrap-hugo-theme/layouts/partials/post-list.html
  50. 161
      themes/minimal-bootstrap-hugo-theme/layouts/partials/style.html
  51. 4
      themes/minimal-bootstrap-hugo-theme/layouts/partials/tags.html
  52. 14
      themes/minimal-bootstrap-hugo-theme/layouts/post/single.html
  53. 8
      themes/minimal-bootstrap-hugo-theme/layouts/shortcodes/blockquote.html
  54. 6
      themes/minimal-bootstrap-hugo-theme/layouts/shortcodes/imgAbs.html
  55. 23
      themes/minimal-bootstrap-hugo-theme/layouts/shortcodes/imgProc.html
  56. 6
      themes/minimal-bootstrap-hugo-theme/layouts/shortcodes/imgRel.html
  57. 7
      themes/minimal-bootstrap-hugo-theme/layouts/taxonomy/taxonomy.html
  58. 14
      themes/minimal-bootstrap-hugo-theme/layouts/taxonomy/terms.html
  59. 8
      themes/minimal-bootstrap-hugo-theme/netlify.toml
  60. 6
      themes/minimal-bootstrap-hugo-theme/static/css/bootstrap.min.css
  61. 7
      themes/minimal-bootstrap-hugo-theme/static/js/bootstrap.bundle.min.js
  62. 2
      themes/minimal-bootstrap-hugo-theme/static/js/jquery-3.3.1.slim.min.js
  63. 15
      themes/minimal-bootstrap-hugo-theme/theme.toml

5
README.md

@ -0,0 +1,5 @@
# hugo_template
New hugo site with minimal-bootstrap-hugo-theme as template.
Create/edit content, or change/edit theme through your gitea user on service provider.

0
archetypes/.gitkeep

6
archetypes/default.md

@ -0,0 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

16
config

@ -0,0 +1,16 @@
[user]
email = sd@sindominio.net
name = sindominio
[commit]
gpgsign = false
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://git.sindominio.net/sindominio/hugo_template.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

50
config.toml

@ -0,0 +1,50 @@
baseURL = ""
languageCode = "es-ES"
title = "Mi nueva web"
theme = "minimal-bootstrap-hugo-theme"
[taxonomies]
tag = "tags"
[permalinks]
post = "/:filename/"
[params]
description = "Texto de ayer y hoy"
contentBackgroundColor = "#fff"
contentTextColor = "#212529"
contentLinkColor = "#007bff"
contentLinkHoverColor = "#0056b3"
navbarBackgroundColor = "#212529"
navbarLinkColor = "rgba(255, 255, 255, 0.75)"
navbarLinkHoverColor = "rgba(255, 255, 255, 1)"
wrapperMaxWidth = "800px"
customDateFormat = "Jan 2, 2006"
customCodeStyle = true
customBlockquoteStyle = true
showPostSummary = false
googleAnalytics = ""
cookieConsent = true
includeBootstrapJs = false
faviconSafariPinnedTabColor = "#5bbad5"
faviconMsApplicationTileColor = "#da532c"
faviconThemeColor = "#ffffff"
[menu]
[[menu.nav]]
name = "Posts"
url = "/"
weight = 1
[[menu.nav]]
name = "Tags"
url = "/tags/"
weight = 2
[[menu.nav]]
name = "About"
url = "/about/"
weight = 3
[[menu.nav]]
name = "RSS"
url = "/index.xml"
weight = 4

0
content/.gitkeep

29
content/about.md

@ -0,0 +1,29 @@
---
title: "About"
date: 2019-06-30T20:57:50+02:00
draft: false
---
## Yo ##
_myself_
**myself**
list:
1. fsdf
2. sfdsdf
3. sfdds
list:
a. fdsf
b. fsdf
c. sdfd
list:
a
b
c
d
Code:
```
ls
cd path
whoami
```

11
content/post/hola_mundo.md

@ -0,0 +1,11 @@
---
title: "Hola_mundo"
date: 2019-07-11T20:26:23+02:00
draft: false
---
¡Hola!
Éste es un artículo de ejemplo.
Puedes añadir más a través de cuenta el gitea, el servidor git de tu proveedor.
Si lo prefieres hacer en local puedes trabajar con git normalmente contra el repo de gitea.

0
data/.gitkeep

0
layouts/.gitkeep

0
static/.gitkeep

0
themes/.gitkeep

20
themes/minimal-bootstrap-hugo-theme/LICENSE

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2018 Zachary Betz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

168
themes/minimal-bootstrap-hugo-theme/README.md

@ -0,0 +1,168 @@
# Minimal Bootstrap Hugo Theme
[![Netlify Status](https://api.netlify.com/api/v1/badges/e3929c16-50cc-4e8f-a8f2-e63acc35c83d/deploy-status)](https://app.netlify.com/sites/minimal-bootstrap-hugo-theme/deploys)
A minimal hugo theme made with bootstrap that focuses on content readability.
## Table of contents
- [Demo](#demo)
- [Minimum Hugo version](#minimum-hugo-version)
- [Installation](#installation)
- [Updating](#updating)
- [Run example site](#run-example-site)
- [Configuration](#configuration)
- [Blog post folder](#blog-post-folder)
- [Favicons](#favicons)
- [Override](#override)
- [Homepage example](#homepage-example)
- [Configure cookie consent](#configure-cookie-consent)
- [Syntax highlighting](#syntax-highlighting)
- [Shortcodes](#shortcodes)
- [`blockquote`](#blockquote)
- [`imgAbs`](#imgabs)
- [`imgRel`](#imgrel)
- [`imgProc`](#imgproc)
- [Getting help](#getting-help)
## Demo
https://minimal-bootstrap-hugo-theme.netlify.com/
## Minimum Hugo version
Hugo version `0.54.0` or higher is required. View the [Hugo releases](https://github.com/gohugoio/hugo/releases) and download the binary for your OS.
## Installation
From the root of your site:
```
git submodule add https://github.com/zwbetz-gh/minimal-bootstrap-hugo-theme.git themes/minimal-bootstrap-hugo-theme
```
## Updating
From the root of your site:
```
git submodule update --remote --merge
```
## Run example site
From the root of `themes/minimal-bootstrap-hugo-theme/exampleSite`:
```
hugo server --themesDir ../..
```
## Configuration
Copy the `config.toml` from the [`exampleSite`](https://github.com/zwbetz-gh/minimal-bootstrap-hugo-theme/tree/master/exampleSite), then edit as desired.
## Blog post folder
This theme expects your _posts_ to be under the `post` folder.
If you want to use a different folder, then override the [`post-list.html`](https://github.com/zwbetz-gh/minimal-bootstrap-hugo-theme/blob/master/layouts/partials/post-list.html) partial and replace `post` with the name of your folder.
## Favicons
Upload your image to [RealFaviconGenerator](https://realfavicongenerator.net/) then copy-paste the generated favicon files under `static`.
## Override
### Homepage example
As an example, let's say you didn't like the default homepage, and wanted to design one of your own. To do this, you would:
1. Copy file `YOUR_SITE/themes/minimal-bootstrap-hugo-theme/layouts/index.html`
1. Paste that file to `YOUR_SITE/layouts/index.html`
1. Edit `index.html` as desired
### Configure cookie consent
You can change the position, layout, color palette, "Learn more" link, compliance type, and custom text of the cookie consent popup. To do this, you would:
1. Copy file `YOUR_SITE/themes/minimal-bootstrap-hugo-theme/layouts/partials/cookie-consent.html`
1. Paste that file to `YOUR_SITE/layouts/partials/cookie-consent.html`
1. Complete the [cookie consent wizard](https://cookieconsent.insites.com/download/)
1. Paste the generated code from the wizard into `cookie-consent.html`
## Syntax highlighting
Hugo has built-in syntax highlighting, provided by Chroma. To use it, add these lines to your `config.toml` right after the `theme` line:
```
pygmentsCodefences = true
pygmentsStyle = "pygments"
```
Here, `"pygments"` is just the name of the Chroma style to be used. Checkout the [Chroma style gallery](https://xyproto.github.io/splash/docs/all.html) and choose the style you like.
For a deeper dive see the [hugo docs for syntax highlighting](https://gohugo.io/content-management/syntax-highlighting/).
## Shortcodes
### `blockquote`
This will format your blockquotes nicely. To use it, put the quote within the shortcode. The `author` argument is optional.
```
{{% blockquote author="Laura Ingalls" %}}
I am beginning to learn that it is the sweet, **simple** things of life which are the real ones after all.
{{% /blockquote %}}
```
### `imgAbs`
This will insert an image into your content by absolute path. To use it, pass the `pathURL` of your image.
These arguments are optional: `alt`, `class`, `style`.
```
{{< imgAbs
pathURL="img/some-img.png"
alt="Some description"
class="some-class"
style="some-style" >}}
```
### `imgRel`
This will insert an image into your content by relative path. To use it, pass the `pathURL` of your image.
These arguments are optional: `alt`, `class`, `style`.
```
{{< imgRel
pathURL="img/some-img.png"
alt="Some description"
class="some-class"
style="some-style" >}}
```
### `imgProc`
This will process an image from a [page bundle](https://gohugo.io/content-management/page-bundles/), then provide a link to the original image. To use it, pass the image name, command, and command options.
The `command` argument will be one of: `Resize`, `Fit`, `Fill`. For a deeper dive see the [hugo docs for image processing](https://gohugo.io/content-management/image-processing/).
These arguments are optional: `alt`, `class`, `style`.
The below example resizes an image to 800px width, while keeping the aspect ratio.
```
{{< imgProc
img="some-img.png"
command="Resize"
options="800x"
alt="Some description"
class="some-class"
style="some-style" >}}
```
## Getting help
If you run into an issue that isn't answered by this documentation or the [`exampleSite`](https://github.com/zwbetz-gh/minimal-bootstrap-hugo-theme/tree/master/exampleSite), then visit the [Hugo forum](https://discourse.gohugo.io/). The folks there are helpful and friendly. **Before** asking your question, be sure to read the [requesting help guidelines](https://discourse.gohugo.io/t/requesting-help/9132). Feel free to tag me in your question, my forum username is [@zwbetz](https://discourse.gohugo.io/u/zwbetz/summary).

5
themes/minimal-bootstrap-hugo-theme/archetypes/default.md

@ -0,0 +1,5 @@
---
title: "{{ replace .Name "-" " " }}"
date: {{ .Date }}
draft: true
---

8
themes/minimal-bootstrap-hugo-theme/archetypes/post.md

@ -0,0 +1,8 @@
---
title: "{{ replace .Name "-" " " }}"
date: {{ .Date }}
publishdate: {{ now.Format "2006-01-02" }}
lastmod: {{ now.Format "2006-01-02" }}
draft: true
tags: []
---

17
themes/minimal-bootstrap-hugo-theme/dev-notes.md

@ -0,0 +1,17 @@
# Dev Notes
## Run Theme Against Example Site Locally
```
hugo server \
--gc \
--source exampleSite \
--config exampleSite/config.toml \
--themesDir ../.. \
--theme minimal-bootstrap-hugo-theme \
--renderToDisk
```
## Screenshots
Use <https://www.befunky.com/> to crop and resize screenshots

49
themes/minimal-bootstrap-hugo-theme/exampleSite/config.toml

@ -0,0 +1,49 @@
baseURL = "https://example.com"
languageCode = "en-us"
title = "Some Title"
theme = "minimal-bootstrap-hugo-theme"
[taxonomies]
tag = "tags"
[permalinks]
post = "/:filename/"
[params]
description = "Some description"
contentBackgroundColor = "#fff"
contentTextColor = "#212529"
contentLinkColor = "#007bff"
contentLinkHoverColor = "#0056b3"
navbarBackgroundColor = "#212529"
navbarLinkColor = "rgba(255, 255, 255, 0.75)"
navbarLinkHoverColor = "rgba(255, 255, 255, 1)"
wrapperMaxWidth = "800px"
customDateFormat = "Jan 2, 2006"
customCodeStyle = true
customBlockquoteStyle = true
showPostSummary = false
googleAnalytics = "UA-123456789-1"
cookieConsent = true
includeBootstrapJs = false
faviconSafariPinnedTabColor = "#5bbad5"
faviconMsApplicationTileColor = "#da532c"
faviconThemeColor = "#ffffff"
[menu]
[[menu.nav]]
name = "Posts"
url = "/"
weight = 1
[[menu.nav]]
name = "Tags"
url = "/tags/"
weight = 2
[[menu.nav]]
name = "About"
url = "/about/"
weight = 3
[[menu.nav]]
name = "RSS"
url = "/index.xml"
weight = 4

28
themes/minimal-bootstrap-hugo-theme/exampleSite/content/about.md

@ -0,0 +1,28 @@
+++
title = "About"
date = "2014-04-09"
+++
## This Theme
Thanks for visiting this theme demo. If you're interested, checkout my other stuff over at <https://zwbetz.com>
## Hugo
Hugo is the **world’s fastest framework for building websites**. It is written in Go.
It makes use of a variety of open source projects including:
* https://github.com/russross/blackfriday
* https://github.com/alecthomas/chroma
* https://github.com/muesli/smartcrop
* https://github.com/spf13/cobra
* https://github.com/spf13/viper
Learn more and contribute on [GitHub](https://github.com/gohugoio).
---
<small>
_Favicon made by [Freepik](https://www.freepik.com/), from [Flaticon](https://www.flaticon.com/), licensed by [CC 3.0](http://creativecommons.org/licenses/by/3.0/)._
</small>

1146
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/creating-a-new-theme.md

File diff suppressed because it is too large

335
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/goisforlovers.md

@ -0,0 +1,335 @@
+++
title = "(Hu)go Template Primer"
date = "2014-04-02"
publishdate = "2014-04-02"
lastmod = "2014-04-02"
draft = false
tags = ["go", "templates", "hugo"]
+++
Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for
its template engine. It is an extremely lightweight engine that provides a very
small amount of logic. In our experience that it is just the right amount of
logic to be able to create a good static website. If you have used other
template systems from different languages or frameworks you will find a lot of
similarities in Go templates.
This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate]
provide more details.
## Introduction to Go Templates
Go templates provide an extremely simple template language. It adheres to the
belief that only the most basic of logic belongs in the template or view layer.
One consequence of this simplicity is that Go templates parse very quickly.
A unique characteristic of Go templates is they are content aware. Variables and
content will be sanitized depending on the context of where they are used. More
details can be found in the [Go docs][gohtmltemplate].
## Basic Syntax
Golang templates are HTML files with the addition of variables and
functions.
**Go variables and functions are accessible within {{ }}**
Accessing a predefined variable "foo":
{{ foo }}
**Parameters are separated using spaces**
Calling the add function with input of 1, 2:
{{ add 1 2 }}
**Methods and fields are accessed via dot notation**
Accessing the Page Parameter "bar"
{{ .Params.bar }}
**Parentheses can be used to group items together**
{{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
## Variables
Each Go template has a struct (object) made available to it. In hugo each
template is passed either a page or a node struct depending on which type of
page you are rendering. More details are available on the
[variables](/layout/variables) page.
A variable is accessed by referencing the variable name.
<title>{{ .Title }}</title>
Variables can also be defined and referenced.
{{ $address := "123 Main St."}}
{{ $address }}
## Functions
Go template ship with a few functions which provide basic functionality. The Go
template system also provides a mechanism for applications to extend the
available functions with their own. [Hugo template
functions](/layout/functions) provide some additional functionality we believe
are useful for building websites. Functions are called by using their name
followed by the required parameters separated by spaces. Template
functions cannot be added without recompiling hugo.
**Example:**
{{ add 1 2 }}
## Includes
When including another template you will pass to it the data it will be
able to access. To pass along the current context please remember to
include a trailing dot. The templates location will always be starting at
the /layout/ directory within Hugo.
**Example:**
{{ template "chrome/header.html" . }}
## Logic
Go templates provide the most basic iteration and conditional logic.
### Iteration
Just like in Go, the Go templates make heavy use of range to iterate over
a map, array or slice. The following are different examples of how to use
range.
**Example 1: Using Context**
{{ range array }}
{{ . }}
{{ end }}
**Example 2: Declaring value variable name**
{{range $element := array}}
{{ $element }}
{{ end }}
**Example 2: Declaring key and value variable name**
{{range $index, $element := array}}
{{ $index }}
{{ $element }}
{{ end }}
### Conditionals
If, else, with, or, & and provide the framework for handling conditional
logic in Go Templates. Like range, each statement is closed with `end`.
Go Templates treat the following values as false:
* false
* 0
* any array, slice, map, or string of length zero
**Example 1: If**
{{ if isset .Params "title" }}<h4>{{ index .Params "title" }}</h4>{{ end }}
**Example 2: If -> Else**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{else}}
{{ index .Params "caption" }}
{{ end }}
**Example 3: And & Or**
{{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
**Example 4: With**
An alternative way of writing "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent.
The first example above could be simplified as:
{{ with .Params.title }}<h4>{{ . }}</h4>{{ end }}
**Example 5: If -> Else If**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{ else if isset .Params "caption" }}
{{ index .Params "caption" }}
{{ end }}
## Pipes
One of the most powerful components of Go templates is the ability to
stack actions one after another. This is done by using pipes. Borrowed
from unix pipes, the concept is simple, each pipeline's output becomes the
input of the following pipe.
Because of the very simple syntax of Go templates, the pipe is essential
to being able to chain together function calls. One limitation of the
pipes is that they only can work with a single value and that value
becomes the last parameter of the next pipeline.
A few simple examples should help convey how to use the pipe.
**Example 1 :**
{{ if eq 1 1 }} Same {{ end }}
is the same as
{{ eq 1 1 | if }} Same {{ end }}
It does look odd to place the if at the end, but it does provide a good
illustration of how to use the pipes.
**Example 2 :**
{{ index .Params "disqus_url" | html }}
Access the page parameter called "disqus_url" and escape the HTML.
**Example 3 :**
{{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
Stuff Here
{{ end }}
Could be rewritten as
{{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
Stuff Here
{{ end }}
## Context (aka. the dot)
The most easily overlooked concept to understand about Go templates is that {{ . }}
always refers to the current context. In the top level of your template this
will be the data set made available to it. Inside of a iteration it will have
the value of the current item. When inside of a loop the context has changed. .
will no longer refer to the data available to the entire page. If you need to
access this from within the loop you will likely want to set it to a variable
instead of depending on the context.
**Example:**
{{ $title := .Site.Title }}
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li>
{{ end }}
Notice how once we have entered the loop the value of {{ . }} has changed. We
have defined a variable outside of the loop so we have access to it from within
the loop.
# Hugo Parameters
Hugo provides the option of passing values to the template language
through the site configuration (for sitewide values), or through the meta
data of each specific piece of content. You can define any values of any
type (supported by your front matter/config format) and use them however
you want to inside of your templates.
## Using Content (page) Parameters
In each piece of content you can provide variables to be used by the
templates. This happens in the [front matter](/content/front-matter).
An example of this is used in this documentation site. Most of the pages
benefit from having the table of contents provided. Sometimes the TOC just
doesn't make a lot of sense. We've defined a variable in our front matter
of some pages to turn off the TOC from being displayed.
Here is the example front matter:
```
---
title: "Permalinks"
date: "2013-11-18"
aliases:
- "/doc/permalinks/"
groups: ["extras"]
groups_weight: 30
notoc: true
---
```
Here is the corresponding code inside of the template:
{{ if not .Params.notoc }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
{{ end }}
## Using Site (config) Parameters
In your top-level configuration file (eg, `config.yaml`) you can define site
parameters, which are values which will be available to you in chrome.
For instance, you might declare:
```yaml
params:
CopyrightHTML: "Copyright &#xA9; 2013 John Doe. All Rights Reserved."
TwitterUser: "spf13"
SidebarRecentLimit: 5
```
Within a footer layout, you might then declare a `<footer>` which is only
provided if the `CopyrightHTML` parameter is provided, and if it is given,
you would declare it to be HTML-safe, so that the HTML entity is not escaped
again. This would let you easily update just your top-level config file each
January 1st, instead of hunting through your templates.
```
{{if .Site.Params.CopyrightHTML}}<footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
</footer>{{end}}
```
An alternative way of writing the "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent:
```
{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
alt="Twitter"></a>
</span>{{end}}
```
Finally, if you want to pull "magic constants" out of your layouts, you can do
so, such as in this example:
```
<nav class="recent">
<h1>Recent Posts</h1>
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
{{end}}</ul>
</nav>
```
[go]: https://golang.org/
[gohtmltemplate]: https://golang.org/pkg/html/template/

81
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/hugoisforlovers.md

@ -0,0 +1,81 @@
+++
title = "Getting Started with Hugo"
date = "2014-04-02"
publishdate = "2014-04-02"
lastmod = "2014-04-02"
draft = false
tags = ["hugo", "git", "fun"]
+++
## Step 1. Install Hugo
Go to [Hugo releases](https://github.com/spf13/hugo/releases) and download the
appropriate version for your OS and architecture.
Save it somewhere specific as we will be using it in the next step.
More complete instructions are available at [Install Hugo](https://gohugo.io/getting-started/installing/)
## Step 2. Build the Docs
Hugo has its own example site which happens to also be the documentation site
you are reading right now.
Follow the following steps:
1. Clone the [Hugo repository](http://github.com/spf13/hugo)
2. Go into the repo
3. Run hugo in server mode and build the docs
4. Open your browser to http://localhost:1313
Corresponding pseudo commands:
git clone https://github.com/spf13/hugo
cd hugo
/path/to/where/you/installed/hugo server --source=./docs
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Press ctrl+c to stop
Once you've gotten here, follow along the rest of this page on your local build.
## Step 3. Change the docs site
Stop the Hugo process by hitting Ctrl+C.
Now we are going to run hugo again, but this time with hugo in watch mode.
/path/to/hugo/from/step/1/hugo server --source=./docs --watch
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Watching for changes in /Users/spf13/Code/hugo/docs/content
> Press ctrl+c to stop
Open your [favorite editor](http://vim.spf13.com) and change one of the source
content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
Content files are found in `docs/content/`. Unless otherwise specified, files
are located at the same relative location as the url, in our case
`docs/content/overview/quickstart.md`.
Change and save this file.. Notice what happened in your terminal.
> Change detected, rebuilding site
> 29 pages created
> 0 tags index created
> in 26 ms
Refresh the browser and observe that the typo is now fixed.
Notice how quick that was. Try to refresh the site before it's finished building. I double dare you.
Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
## Step 4. Have fun
The best way to learn something is to play with it.

154
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/migrate-from-jekyll.md

@ -0,0 +1,154 @@
---
title: "Migrate to Hugo from Jekyll"
date: 2014-03-10
publishdate: 2014-03-10
lastmod: 2014-03-10
draft: false
tags: ["hugo", "jekyll", "migration", "git", "templates"]
---
## Move static content to `static`
Jekyll has a rule that any directory not starting with `_` will be copied as-is to the `_site` output. Hugo keeps all static content under `static`. You should therefore move it all there.
With Jekyll, something that looked like
<root>/
▾ images/
logo.png
should become
<root>/
▾ static/
▾ images/
logo.png
Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
## Create your Hugo configuration file
Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the [Hugo configuration documentation](/overview/configuration/) for details.
## Set your configuration publish folder to `_site`
The default is for Jekyll to publish to `_site` and for Hugo to publish to `public`. If, like me, you have [`_site` mapped to a git submodule on the `gh-pages` branch](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html), you'll want to do one of two alternatives:
1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
git submodule deinit _site
git rm _site
git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
2. Or, change the Hugo configuration to use `_site` instead of `public`.
{
..
"publishdir": "_site",
..
}
## Convert Jekyll templates to Hugo templates
That's the bulk of the work right here. The documentation is your friend. You should refer to [Jekyll's template documentation](http://jekyllrb.com/docs/templates/) if you need to refresh your memory on how you built your blog and [Hugo's template](/layout/templates/) to learn Hugo's way.
As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
## Convert Jekyll plugins to Hugo shortcodes
Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
### Implementation
As an example, I was using a custom [`image_tag`](https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb) plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.
Jekyll's plugin:
module Jekyll
class ImageTag < Liquid::Tag
@url = nil
@caption = nil
@class = nil
@link = nil
// Patterns
IMAGE_URL_WITH_CLASS_AND_CAPTION =
IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
def initialize(tag_name, markup, tokens)
super
if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
@class = $1
@url = $3
@caption = $7
@link = $9
elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
@class = $1
@url = $3
@caption = $7
elsif markup =~ IMAGE_URL_WITH_CAPTION
@url = $1
@caption = $5
elsif markup =~ IMAGE_URL_WITH_CLASS
@class = $1
@url = $3
elsif markup =~ IMAGE_URL
@url = $1
end
end
def render(context)
if @class
source = "<figure class='#{@class}'>"
else
source = "<figure>"
end
if @link
source += "<a href=\"#{@link}\">"
end
source += "<img src=\"#{@url}\">"
if @link
source += "</a>"
end
source += "<figcaption>#{@caption}</figcaption>" if @caption
source += "</figure>"
source
end
end
end
Liquid::Template.register_tag('image', Jekyll::ImageTag)
is written as this Hugo shortcode:
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
{{ .Get "title" }}{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->
### Usage
I simply changed:
{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "One of my favorite touristy-type photos. I secretly waited for the good light while we were "having fun" and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`):
{{%/* fig class="full" src="http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg" title="One of my favorite touristy-type photos. I secretly waited for the good light while we were having fun and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." link="http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/" */%}}
As a bonus, the shortcode named parameters are, arguably, more readable.
## Finishing touches
### Fix content
Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that `hugo server --watch` is your friend. Test your changes and fix errors as needed.
### Clean up
You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
## A practical example in a diff
[Hey, it's Alex](http://heyitsalex.net/) was migrated in less than a _father-with-kids day_ from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this [diff](https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610).

98
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/script-to-add-a-page-level-variable-to-content-front-matter-in-hugo.md

@ -0,0 +1,98 @@
---
title: "Script to add a page-level variable to content front matter in hugo"
date: 2018-10-10T12:43:20-05:00
publishdate: 2018-10-10
lastmod: 2018-10-11
draft: false
tags: ["hugo", "command-line", "awk"]
---
This was originally a question posed on the [hugo discussion forums](https://discourse.gohugo.io/t/set-frontmatter-params-in-list-template/14645).
The user wanted to loop through all her content files and add a `weight` page-level variable to the front matter. The value of `weight` needed to be the first 2 characters of the content filename, since her content was named like `01_content.md`, `02_content.md`, etc.
She then wanted to `range` through her pages by their weight, like so:
```go
{{ range .Pages.ByWeight }}
<!-- some code -->
{{ end }}
```
## The script
```bash
#!/bin/bash
for file in *.md; do
weight=${file:0:2}
awk -v weight=$weight '/---/{
count++
if(count == 2){
sub("---","weight: " weight "\n---",$0)
}
}
{print}' $file > tmp && mv tmp $file
done
```
## Explained
Loop through all files in the directory with extension `.md`:
```bash
for file in *.md; do
# ...
done
```
Set a variable using the first 2 characters of the filename:
```bash
weight=${file:0:2}
```
Call an `awk` program and pass it a `weight` variable:
```bash
awk -v weight=$weight
```
When the `awk` program encounters the 2nd occurrence of `---` (which is how you end front matter in YAML), it inserts the `weight` page-level variable on the line above:
```bash
'/---/{
count++
if(count == 2){
sub("---","weight: " weight "\n---",$0)
}
}
{print}'
```
Redirect the output of the `awk` program to a tmp file, then overwrite the original content file with the tmp file:
```bash
> tmp && mv tmp $file
```
## Result
Original `01_content.md`:
```yml
---
title: "Some title"
draft: false
---
```
Updated `01_content.md`:
```yml
---
title: "Some title"
draft: false
weight: 01
---
```

88
themes/minimal-bootstrap-hugo-theme/exampleSite/content/post/use-snap-to-install-the-hugo-edge-version-on-fedora-and-ubuntu.md

@ -0,0 +1,88 @@
---
title: "Use Snap to install the Hugo edge version on Fedora and Ubuntu"
date: 2018-10-26T12:59:51-05:00
publishdate: 2018-10-26
lastmod: 2018-10-26
draft: false
aliases:
- /use-snap-to-install-the-hugo-edge-version-on-fedora/
tags: ["hugo", "snap", "fedora", "ubuntu"]
---
If you are using the Fedora or Ubuntu Linux distributions -- I'm currently on Fedora 28 -- and would like to [help test the latest development version of Hugo](https://discourse.gohugo.io/t/help-test-upcoming-hugo-0-50/14880), or if you just want to be on the bleeding-edge of things, this post is for you.
## Fedora-only steps
To get started, [install Snap on Fedora](https://docs.snapcraft.io/installing-snap-on-fedora/6755):
```
sudo dnf install snapd
```
Add the [Snap directory](https://docs.snapcraft.io/commands-and-aliases/3950) to your `PATH` by adding this line to your `~/.bashrc` file. Then restart your terminal to pick up the change:
```
export PATH="$PATH:/var/lib/snapd/snap/bin"
```
## Ubuntu-only steps
Ubuntu 16.04 and above come with [Snap already installed](https://docs.snapcraft.io/installing-snap-on-ubuntu/6740). If you're using an older Ubuntu version, install Snap by running:
```
sudo apt update && sudo apt install snapd
```
Check if the Snap directory is on your `PATH` by listing each entry:
```
echo $PATH | tr ':' '\n'
```
If you don't see `/snap/bin` listed, then add this line to your `~/.bashrc` file. Then restart your terminal to pick up the change:
```
export PATH="$PATH:/snap/bin"
```
## Install Hugo
See which Snap channels are available for Hugo:
```
snap info hugo
```
Install Hugo from the edge channel:
```
sudo snap install hugo --channel=edge
```
Or, if you prefer Hugo Extended -- which has the [Hugo Pipes](https://gohugo.io/hugo-pipes/) feature -- install it from the extended edge channel:
```
sudo snap install hugo --channel=extended/edge
```
Lastly, confirm the location and version of Hugo that was intalled:
```
which hugo && hugo version
```
Happy testing :)
## Update or remove Hugo
Snaps are [updated automatically](https://docs.snapcraft.io/keeping-snaps-up-to-date/7022). To manually update Hugo:
```
sudo snap refresh hugo
```
To remove Hugo:
```
sudo snap remove hugo
```

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/android-chrome-192x192.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/android-chrome-256x256.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/apple-touch-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

9
themes/minimal-bootstrap-hugo-theme/exampleSite/static/browserconfig.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon-32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
themes/minimal-bootstrap-hugo-theme/exampleSite/static/mstile-150x150.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

46
themes/minimal-bootstrap-hugo-theme/exampleSite/static/safari-pinned-tab.svg

@ -0,0 +1,46 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="256.000000pt" height="256.000000pt" viewBox="0 0 256.000000 256.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,256.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M750 2540 c-159 -34 -261 -81 -366 -167 -97 -78 -182 -183 -221 -271
-19 -46 -2 -71 65 -95 64 -22 138 -72 175 -119 24 -29 30 -47 29 -80 -1 -55
-13 -84 -134 -310 -144 -269 -189 -392 -208 -568 -18 -161 9 -319 80 -468 87
-182 216 -319 378 -401 120 -61 125 -61 707 -61 400 0 534 3 543 12 32 32 -1
169 -55 229 -44 49 -107 69 -215 69 l-78 0 18 38 c19 36 55 143 66 192 5 23
14 27 91 43 161 33 295 97 416 198 39 32 82 62 95 65 13 3 45 0 72 -6 82 -22
224 13 256 62 15 23 15 29 -4 83 -28 82 -66 142 -100 160 l-29 15 51 51 c48
48 50 52 44 92 -4 23 -30 89 -58 146 -89 181 -245 314 -412 352 -50 11 -56 16
-70 49 -8 20 -30 57 -50 83 -28 37 -36 56 -36 90 0 45 -13 67 -40 67 -30 0
-50 -34 -50 -82 0 -48 -45 -164 -54 -137 -2 7 -12 45 -21 83 -26 113 -71 217
-135 314 -95 144 -209 230 -360 271 -97 27 -268 28 -390 1z m359 -85 c94 -25
163 -65 237 -139 58 -58 80 -90 122 -176 56 -114 97 -244 108 -338 l6 -60 -73
-42 c-99 -57 -163 -104 -231 -168 l-57 -54 -51 11 c-252 54 -530 -87 -647
-329 -52 -107 -73 -202 -73 -329 0 -168 50 -372 96 -393 20 -9 28 -8 41 5 18
18 14 49 -23 177 -9 30 -18 109 -21 175 -6 139 8 218 59 324 38 80 149 196
224 234 127 64 266 72 403 24 55 -19 79 -23 93 -16 22 12 24 52 4 69 -13 10
-7 19 34 55 57 51 147 113 207 144 52 26 51 26 55 0 2 -12 12 -28 23 -35 31
-21 65 6 65 51 0 48 19 131 42 185 l20 45 19 -35 c10 -19 30 -72 44 -117 22
-69 30 -84 51 -89 32 -8 54 11 54 47 0 38 12 37 97 -6 115 -57 221 -180 279
-323 26 -65 21 -81 -30 -106 -43 -20 -84 -20 -158 0 -47 13 -61 14 -73 4 -25
-21 -18 -58 15 -79 l31 -18 -28 -11 c-69 -26 -109 -33 -234 -42 -109 -7 -136
-12 -146 -26 -19 -26 -16 -42 11 -60 38 -24 257 -3 381 36 95 31 173 38 220
20 18 -7 34 -27 51 -65 13 -31 24 -57 24 -60 0 -2 -25 -9 -56 -15 -41 -9 -68
-9 -99 -1 -95 24 -135 11 -236 -74 -98 -84 -276 -167 -401 -189 -42 -8 -41 -8
-52 86 -12 105 -90 209 -195 263 -94 47 -279 73 -309 43 -38 -38 4 -73 98 -81
130 -12 225 -59 277 -136 69 -102 59 -290 -24 -459 l-35 -72 -44 0 c-35 0 -47
-5 -59 -24 -13 -19 -14 -29 -5 -45 10 -20 19 -21 186 -21 183 0 221 -7 256
-47 10 -11 21 -34 24 -51 l7 -32 -491 0 c-459 0 -494 1 -553 20 -126 38 -250
134 -345 266 -99 138 -146 286 -145 464 0 195 46 333 220 655 101 186 123 244
124 316 1 98 -64 180 -198 251 l-64 33 31 49 c63 102 198 211 328 266 130 54
371 77 489 45z"/>
<path d="M2040 1490 c-41 -41 -10 -110 48 -110 36 0 62 28 62 67 0 57 -69 84
-110 43z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

19
themes/minimal-bootstrap-hugo-theme/exampleSite/static/site.webmanifest

@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

256
themes/minimal-bootstrap-hugo-theme/gh-md-toc

@ -0,0 +1,256 @@
#!/usr/bin/env bash
#
# Steps:
#
# 1. Download corresponding html file for some README.md:
# curl -s $1
#
# 2. Discard rows where no substring 'user-content-' (github's markup):
# awk '/user-content-/ { ...
#
# 3.1 Get last number in each row like ' ... </span></a>sitemap.js</h1'.
# It's a level of the current header:
# substr($0, length($0), 1)
#
# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
# sprintf("%*s", substr($0, length($0), 1)*3, " ")
#
# 4. Find head's text and insert it inside "* [ ... ]":
# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
#
# 5. Find anchor and insert it inside "(...)":
# substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8)
#
gh_toc_version="0.5.0"
gh_user_agent="gh-md-toc v$gh_toc_version"
#
# Download rendered into html README.md by its url.
#
#
gh_toc_load() {
local gh_url=$1
if type curl &>/dev/null; then
curl --user-agent "$gh_user_agent" -s "$gh_url"
elif type wget &>/dev/null; then
wget --user-agent="$gh_user_agent" -qO- "$gh_url"
else
echo "Please, install 'curl' or 'wget' and try again."
exit 1
fi
}
#
# Converts local md file into html by GitHub
#
# ➥ curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown
# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
gh_toc_md2html() {
local gh_file_md=$1
URL=https://api.github.com/markdown/raw
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
if [ -f "$TOKEN" ]; then
URL="$URL?access_token=$(cat $TOKEN)"
fi
OUTPUT="$(curl -s --user-agent "$gh_user_agent" \
--data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
$URL)"
if [ "$?" != "0" ]; then
echo "XXNetworkErrorXX"
fi
if [ "$(echo "${OUTPUT}" | awk '/API rate limit exceeded/')" != "" ]; then
echo "XXRateLimitXX"
else
echo "${OUTPUT}"
fi
}
#
# Is passed string url
#
gh_is_url() {
case $1 in
https* | http*)
echo "yes";;
*)
echo "no";;
esac
}
#
# TOC generator
#
gh_toc(){
local gh_src=$1
local gh_src_copy=$1
local gh_ttl_docs=$2
local need_replace=$3
if [ "$gh_src" = "" ]; then
echo "Please, enter URL or local path for a README.md"
exit 1
fi
# Show "TOC" string only if working with one document
if [ "$gh_ttl_docs" = "1" ]; then
echo "Table of Contents"
echo "================="
echo ""
gh_src_copy=""
fi
if [ "$(gh_is_url "$gh_src")" == "yes" ]; then
gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy"
if [ "${PIPESTATUS[0]}" != "0" ]; then
echo "Could not load remote document."
echo "Please check your url or network connectivity"
exit 1
fi
if [ "$need_replace" = "yes" ]; then
echo
echo "!! '$gh_src' is not a local file"
echo "!! Can't insert the TOC into it."
echo
fi
else
local rawhtml=$(gh_toc_md2html "$gh_src")
if [ "$rawhtml" == "XXNetworkErrorXX" ]; then
echo "Parsing local markdown file requires access to github API"
echo "Please make sure curl is installed and check your network connectivity"
exit 1
fi
if [ "$rawhtml" == "XXRateLimitXX" ]; then
echo "Parsing local markdown file requires access to github API"
echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting"
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
echo "or place github auth token here: $TOKEN"
exit 1
fi
local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy"`
echo "$toc"
if [ "$need_replace" = "yes" ]; then
local ts="<\!--ts-->"
local te="<\!--te-->"
local dt=`date +'%F_%H%M%S'`
local ext=".orig.${dt}"
local toc_path="${gh_src}.toc.${dt}"
local toc_footer="<!-- Added by: `whoami`, at: `date --iso-8601='minutes'` -->"
# http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
# clear old TOC
sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src"
# create toc file
echo "${toc}" > "${toc_path}"
echo -e "\n${toc_footer}\n" >> "$toc_path"
# insert toc file
if [[ "`uname`" == "Darwin" ]]; then
sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
else
sed -i "/${ts}/r ${toc_path}" "$gh_src"
fi
echo
echo "!! TOC was added into: '$gh_src'"
echo "!! Origin version of the file: '${gh_src}${ext}'"
echo "!! TOC added into a separate file: '${toc_path}'"
echo
fi
fi
}
#
# Grabber of the TOC from rendered html
#
# $1 — a source url of document.
# It's need if TOC is generated for multiple documents.
#
gh_toc_grab() {
# if closed <h[1-6]> is on the new line, then move it on the prev line
# for example:
# was: The command <code>foo1</code>
# </h1>
# became: The command <code>foo1</code></h1>
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
# find strings that corresponds to template
grep -E -o '<a.*id="user-content-[^"]*".*</h[1-6]' |
# remove code tags
sed 's/<code>//' | sed 's/<\/code>//' |
# now all rows are like:
# <a id="user-content-..." href="..."><span ...></span></a> ... </h1
# format result line
# * $0 — whole string
echo -e "$(awk -v "gh_url=$1" '{
print sprintf("%*s", substr($0, length($0), 1)*3, " ") "* [" substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')"
}
#
# Returns filename only from full path or url
#
gh_toc_get_filename() {
echo "${1##*/}"
}
#
# Options hendlers
#
gh_toc_app() {
local app_name=$(basename $0)
local need_replace="no"
if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then
echo "GitHub TOC generator ($app_name): $gh_toc_version"
echo ""
echo "Usage:"
echo " $app_name [--insert] src [src] Create TOC for a README file (url or local path)"
echo " $app_name - Create TOC for markdown from STDIN"
echo " $app_name --help Show help"
echo " $app_name --version Show version"
return
fi
if [ "$1" = '--version' ]; then
echo "$gh_toc_version"
return
fi
if [ "$1" = "-" ]; then
if [ -z "$TMPDIR" ]; then
TMPDIR="/tmp"
elif [ -n "$TMPDIR" -a ! -d "$TMPDIR" ]; then
mkdir -p "$TMPDIR"
fi
local gh_tmp_md
gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX)
while read input; do
echo "$input" >> "$gh_tmp_md"
done
gh_toc_md2html "$gh_tmp_md" | gh_toc_grab ""
return
fi
if [ "$1" = '--insert' ]; then
need_replace="yes"
shift
fi
for md in "$@"
do
echo ""
gh_toc "$md" "$#" "$need_replace"
done
echo ""
echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
}
#
# Entry point
#
gh_toc_app "$@"

BIN
themes/minimal-bootstrap-hugo-theme/images/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
themes/minimal-bootstrap-hugo-theme/images/tn.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

20
themes/minimal-bootstrap-hugo-theme/layouts/_default/baseof.html

@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}
<div class="container">
<article>
{{ block "main" . }}{{ end }}
</article>
</div>
{{ partial "bootstrap-js.html" . }}
{{ partial "google-analytics-async.html" . }}
{{ partial "cookie-consent.html" . }}
</body>
</html>

0
themes/minimal-bootstrap-hugo-theme/layouts/_default/list.html

6
themes/minimal-bootstrap-hugo-theme/layouts/_default/single.html

@ -0,0 +1,6 @@
{{- define "main" -}}
<h1>{{ .Title | markdownify }}</h1>
{{ .Content }}
{{- end -}}

13
themes/minimal-bootstrap-hugo-theme/layouts/index.html

@ -0,0 +1,13 @@
{{- define "main" -}}
{{ $homepage := "Home" }}
{{ with .Site.Menus.nav }}
{{ range first 1 . }}
{{ $homepage = .Name }}
{{ end }}
{{ end }}
<h1>{{ $homepage }}</h1>
{{ partial "post-list" . }}
{{- end -}}

6
themes/minimal-bootstrap-hugo-theme/layouts/partials/bootstrap-js.html

@ -0,0 +1,6 @@
{{ if eq .Site.Params.includeBootstrapJs true}}
{{ $jqueryJs := "js/jquery-3.3.1.slim.min.js" -}}
<script src="{{ $jqueryJs | absURL }}"></script>
{{ $bootstrapJs := "js/bootstrap.bundle.min.js" -}}
<script src="{{ $bootstrapJs | absURL }}"></script>
{{ end }}

18
themes/minimal-bootstrap-hugo-theme/layouts/partials/cookie-consent.html

@ -0,0 +1,18 @@
{{ if eq .Site.Params.cookieConsent true }}
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#216942",
"text": "#b2d192"
},
"button": {
"background": "#afed71"
}
}
})});
</script>
{{ end }}

10
themes/minimal-bootstrap-hugo-theme/layouts/partials/google-analytics-async.html

@ -0,0 +1,10 @@
{{ if not .Site.IsServer }}
{{ with .Site.Params.googleAnalytics }}
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
{{ end }}
{{ end }}

13
themes/minimal-bootstrap-hugo-theme/layouts/partials/google-analytics.html

@ -0,0 +1,13 @@
{{ if not .Site.IsServer }}
{{ with .Site.Params.googleAnalytics }}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
</script>
{{ end }}
{{ end }}

46
themes/minimal-bootstrap-hugo-theme/layouts/partials/head.html

@ -0,0 +1,46 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{ hugo.Generator }}
{{ with .Site.Params.description }}
<meta name="description" content="{{ . }}">
{{ end }}
{{ $appleTouchIcon := "apple-touch-icon.png" }}
<link rel="apple-touch-icon" sizes="180x180" href="{{ $appleTouchIcon | absURL }}">
{{ $favicon32x32 := "favicon-32x32.png" }}
<link rel="icon" type="image/png" sizes="32x32" href="{{ $favicon32x32 | absURL }}">
{{ $favicon16x16 := "favicon-16x16.png" }}
<link rel="icon" type="image/png" sizes="16x16" href="{{ $favicon16x16 | absURL }}">
{{ $siteWebmanifest := "site.webmanifest" }}
<link rel="manifest" href="{{ $siteWebmanifest | absURL }}">
{{ $safariPinnedTab := "safari-pinned-tab.svg" }}
<link rel="mask-icon" href="{{ $safariPinnedTab | absURL }}" color="{{ .Site.Params.faviconSafariPinnedTabColor }}">
<meta name="msapplication-TileColor" content="{{ .Site.Params.faviconMsApplicationTileColor }}">
<meta name="theme-color" content="{{ .Site.Params.faviconThemeColor }}">
{{ $bootstrapCss := "css/bootstrap.min.css" }}
<link rel="stylesheet" href="{{ $bootstrapCss | absURL }}" />
{{ if .IsHome }}
{{ $homepage := "Home" }}
{{ with .Site.Menus.nav }}
{{ range first 1 . }}
{{ $homepage = .Name }}
{{ end }}
{{ end }}
<title>{{ $homepage }} | {{ .Site.Title }}</title>
{{ else }}
<title>{{ .Title }} | {{ .Site.Title }}</title>
{{ end }}
{{ partial "style.html" . }}
</head>

7
themes/minimal-bootstrap-hugo-theme/layouts/partials/nav.html

@ -0,0 +1,7 @@
<nav class="custom-navbar">
<div class="container">
{{ range .Site.Menus.nav }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</div>
</nav>

14
themes/minimal-bootstrap-hugo-theme/layouts/partials/post-list.html

@ -0,0 +1,14 @@
{{ range where .Pages.ByPublishDate.Reverse "Section" "post" }}
<p>
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ $customDateFormat := "January 2, 2006" }}
{{ with .Site.Params.customDateFormat }}{{ $customDateFormat = . }}{{ end }}
<br>
<small class="text-secondary">{{ .PublishDate.Format $customDateFormat }}</small>
{{ partial "tags" . }}
{{ if eq .Site.Params.showPostSummary true }}
<br>
{{ .Summary }}
{{ end }}
</p>
{{ end }}

161
themes/minimal-bootstrap-hugo-theme/layouts/partials/style.html