├── layouts ├── 404.html ├── _default │ ├── single.html │ ├── list.html │ ├── terms.html │ └── baseof.html ├── post │ └── single.html ├── partials │ ├── footer.html │ ├── script.html │ ├── google-analytics-async.html │ ├── date-and-tags.html │ ├── head.html │ ├── katex.html │ ├── nav.html │ └── style.html ├── shortcodes │ ├── bootstrap-table.html │ ├── bootstrap-blockquote.html │ ├── bootstrap-card-list.html │ └── bootstrap-card.html └── index.html ├── .gitattributes ├── .gitignore ├── exampleSite ├── content │ ├── post │ │ ├── _index.md │ │ ├── nasa-images │ │ │ ├── sun.jpg │ │ │ ├── earth.jpg │ │ │ ├── moon.jpg │ │ │ └── index.md │ │ ├── katex-math-typesetting │ │ │ └── index.md │ │ ├── style-a-markdown-table-with-bootstrap-classes-in-hugo.md │ │ ├── quotes-by-carl-jung.md │ │ ├── script-to-add-a-page-level-variable-to-content-front-matter-in-hugo.md │ │ ├── use-snap-to-install-the-hugo-edge-version-on-fedora-and-ubuntu.md │ │ ├── hugoisforlovers.md │ │ ├── migrate-from-jekyll.md │ │ ├── goisforlovers.md │ │ └── creating-a-new-theme.md │ ├── _index.md │ └── about.md ├── static │ └── favicon.ico ├── resources │ └── _gen │ │ └── images │ │ ├── nasa-images │ │ ├── moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg │ │ ├── sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg │ │ └── earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg │ │ └── post │ │ └── nasa-images │ │ ├── moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg │ │ ├── sun_huc3d26fbb16c0f70400041133778c1446_3118921_100x0_resize_q75_box.jpg │ │ ├── sun_huc3d26fbb16c0f70400041133778c1446_3118921_400x0_resize_q75_box.jpg │ │ ├── sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg │ │ ├── earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg │ │ └── sun_huc3d26fbb16c0f70400041133778c1446_3118921_1000x0_resize_q75_box.jpg └── config.yaml ├── images ├── tn.png └── screenshot.png ├── task_serve.sh ├── archetypes └── default.md ├── netlify.toml ├── theme.toml ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── LICENSE ├── README.md ├── gh-md-toc └── static └── js └── feather.min.js /layouts/404.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | gh-md-toc linguist-vendored 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | exampleSite/public/ 2 | local_git_config.sh 3 | -------------------------------------------------------------------------------- /exampleSite/content/post/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Blog 3 | --- -------------------------------------------------------------------------------- /images/tn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/images/tn.png -------------------------------------------------------------------------------- /task_serve.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd exampleSite 4 | hugo serve --themesDir ../.. 5 | cd .. 6 | -------------------------------------------------------------------------------- /exampleSite/content/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Home 3 | draft: false 4 | --- 5 | 6 | Homepage content goes here. 7 | -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/images/screenshot.png -------------------------------------------------------------------------------- /layouts/_default/single.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 | 3 |

{{ .Title }}

4 | {{ .Content }} 5 | 6 | {{ end }} -------------------------------------------------------------------------------- /archetypes/default.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "{{ replace .Name "-" " " | title }}" 3 | date: {{ .Date }} 4 | tags: [] 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /exampleSite/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/static/favicon.ico -------------------------------------------------------------------------------- /exampleSite/content/post/nasa-images/sun.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/content/post/nasa-images/sun.jpg -------------------------------------------------------------------------------- /exampleSite/content/post/nasa-images/earth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/content/post/nasa-images/earth.jpg -------------------------------------------------------------------------------- /exampleSite/content/post/nasa-images/moon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/content/post/nasa-images/moon.jpg -------------------------------------------------------------------------------- /layouts/post/single.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 | 3 |

{{ .Title }}

4 | {{ partial "date-and-tags.html" . }} 5 |

6 | {{ .Content }} 7 | 8 | {{ end }} -------------------------------------------------------------------------------- /layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 | {{ if ne .Site.Params.hideFooter true }} 2 | 7 | {{ end }} -------------------------------------------------------------------------------- /layouts/shortcodes/bootstrap-table.html: -------------------------------------------------------------------------------- 1 | {{ $htmlTable := .Inner | markdownify }} 2 | {{ $class := .Get 0 }} 3 | {{ $old := "" }} 4 | {{ $new := printf "
" $class }} 5 | {{ $htmlTable := replace $htmlTable $old $new }} 6 | {{ $htmlTable | safeHTML }} -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/nasa-images/moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/nasa-images/moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/nasa-images/earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/nasa-images/earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /layouts/_default/list.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 | 3 |

{{ .Title }}

4 | 5 | {{ range .Pages.ByPublishDate.Reverse }} 6 |

7 | {{ .Title }} 8 |
9 | {{ partial "date-and-tags.html" . }} 10 |

11 | {{ end }} 12 | 13 | {{ end }} -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/moon_huaae7be4ba70df7325b57cd351ea21ee7_381038_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_100x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_100x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_400x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_400x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/earth_huaae7be4ba70df7325b57cd351ea21ee7_518573_700x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_1000x0_resize_q75_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/HEAD/exampleSite/resources/_gen/images/post/nasa-images/sun_huc3d26fbb16c0f70400041133778c1446_3118921_1000x0_resize_q75_box.jpg -------------------------------------------------------------------------------- /layouts/index.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 | 3 |
4 | {{ with .Content }} 5 |

{{ $.Page.Title }}

6 | {{ . }} 7 | {{ else }} 8 |

{{ .Site.Title }}

9 |

{{ .Site.Params.homeText | markdownify }}

10 | {{ end }} 11 |
12 | 13 | {{ end }} -------------------------------------------------------------------------------- /layouts/partials/script.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | {{ if eq .Site.Params.includeBootstrapJs true }} 7 | 8 | 9 | {{ end }} -------------------------------------------------------------------------------- /layouts/_default/terms.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 | 3 |

{{ .Title }}

4 | 5 | {{ range .Data.Terms.Alphabetical }} 6 |

7 | 8 | {{ .Count }} {{ .Page.Title }} 9 | 10 |

11 | {{ end }} 12 | 13 | {{ end }} -------------------------------------------------------------------------------- /layouts/shortcodes/bootstrap-blockquote.html: -------------------------------------------------------------------------------- 1 | {{ $quote := .Inner }} 2 | {{ $quote = replace $quote "

" "" }} 3 | {{ $quote = replace $quote "

" "" }} 4 | {{ $quote = safeHTML $quote }} 5 |
6 |

{{ $quote }}

7 | {{ with (.Get "author") }} 8 | 9 | {{ end }} 10 |
-------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "exampleSite/public" 3 | command = "cd exampleSite && hugo --themesDir ../.." 4 | 5 | [build.environment] 6 | HUGO_VERSION = "0.83.1" 7 | HUGO_THEME = "repo" 8 | HUGO_BASEURL = "https://vanilla-bootstrap-hugo-theme.netlify.app" 9 | 10 | [[headers]] 11 | for = "/*" 12 | [headers.values] 13 | Access-Control-Allow-Origin = "*" 14 | -------------------------------------------------------------------------------- /layouts/partials/google-analytics-async.html: -------------------------------------------------------------------------------- 1 | {{ if not .Site.IsServer }} 2 | {{ with .Site.GoogleAnalytics }} 3 | 8 | 9 | {{ end }} 10 | {{ end }} -------------------------------------------------------------------------------- /layouts/partials/date-and-tags.html: -------------------------------------------------------------------------------- 1 | {{ $dateTime := .PublishDate.Format "2006-01-02" }} 2 | {{ $dateFormat := .Site.Params.dateFormat | default "Jan 2, 2006" }} 3 | 4 | {{ with .Params.tags }} 5 |
6 | 7 | {{ range . }} 8 | {{ $href := print (absURL "tags/") (urlize .) }} 9 | {{ . }} 10 | {{ end }} 11 | {{ end }} -------------------------------------------------------------------------------- /exampleSite/content/about.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2014-04-09" 3 | title: "About" 4 | --- 5 | 6 | Hugo is the **world’s fastest framework for building websites**. It is written in Go. 7 | 8 | It makes use of a variety of open source projects including: 9 | 10 | * https://github.com/russross/blackfriday 11 | * https://github.com/alecthomas/chroma 12 | * https://github.com/muesli/smartcrop 13 | * https://github.com/spf13/cobra 14 | * https://github.com/spf13/viper 15 | 16 | Learn more and contribute on [GitHub](https://github.com/gohugoio). 17 | -------------------------------------------------------------------------------- /theme.toml: -------------------------------------------------------------------------------- 1 | name = "Vanilla Bootstrap" 2 | license = "MIT" 3 | licenselink = "https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/blob/master/LICENSE" 4 | description = "A vanilla Bootstrap theme for Hugo" 5 | homepage = "https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme" 6 | tags = ["home", "blog", "tags", "bootstrap", "minimal", "clean", "simple", "feather"] 7 | features = ["home", "blog", "tags", "bootstrap", "minimal", "clean", "simple", "feather"] 8 | min_version = "0.81.0" 9 | 10 | [author] 11 | name = "Zachary Betz" 12 | homepage = "https://zwbetz.com/" 13 | -------------------------------------------------------------------------------- /layouts/_default/baseof.html: -------------------------------------------------------------------------------- 1 | 2 | {{ $lang := .Site.Language.Lang | default "en" }} 3 | 4 | {{ partial "head.html" . }} 5 | 6 | {{ partial "nav.html" . }} 7 |
8 |
9 | {{ block "main" . }}{{ end }} 10 |
11 |
12 | {{ partial "footer.html" . }} 13 | {{ partial "script.html" . }} 14 | {{ partial "katex.html" . }} 15 | {{ partial "google-analytics-async.html" . }} 16 | 17 | -------------------------------------------------------------------------------- /layouts/partials/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ hugo.Generator }} 5 | {{ $summary := trim (.Summary | plainify | htmlUnescape) "\n\r" 6 | | default .Title }} 7 | 8 | 9 | {{ $title := print .Title " | " .Site.Title }} 10 | {{ if .IsHome }} 11 | {{ $title = .Site.Title }} 12 | {{ end }} 13 | {{ $title }} 14 | {{ partial "style.html" . }} 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /exampleSite/content/post/katex-math-typesetting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Katex Math Typesetting" 3 | date: 2020-02-28 4 | tags: [katex, math, typesetting, hugo] 5 | --- 6 | 7 | Enable Katex in the config file by setting the `katex` param to `true`. This will import the necessary Katex CSS/JS. 8 | 9 | **Note:** Use the online reference of [supported TeX functions](https://katex.org/docs/supported.html). 10 | 11 | Some math: 12 | 13 | ``` 14 | $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ 15 | ``` 16 | 17 | $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ 18 | 19 | More math: 20 | 21 | ``` 22 | $$ 23 | \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } 24 | $$ 25 | ``` 26 | 27 | $$ 28 | \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } 29 | $$ 30 | -------------------------------------------------------------------------------- /layouts/shortcodes/bootstrap-card-list.html: -------------------------------------------------------------------------------- 1 | {{ $command := .Get "command" }} 2 | {{ $options := .Get "options" }} 3 | {{ $alt := .Get "alt" }} 4 | {{ $class := .Get "class" }} 5 | {{ $style := .Get "style" }} 6 | 7 | {{ with .Page.Resources.ByType "image" }} 8 | {{ range . }} 9 | 10 | {{ $original := . }} 11 | {{ $new := "" }} 12 | 13 | {{ if eq $command "Fit" }} 14 | {{ $new = $original.Fit $options }} 15 | {{ else if eq $command "Resize" }} 16 | {{ $new = $original.Resize $options }} 17 | {{ else if eq $command "Fill" }} 18 | {{ $new = $original.Fill $options }} 19 | {{ else }} 20 | {{ errorf "Invalid image processing command: Must be one of Fit, Fill, or Resize." }} 21 | {{ end }} 22 | 23 |
24 | 25 | {{ $alt }} 26 | 27 |
28 | 29 | {{ end }} 30 | {{ end }} -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /layouts/partials/katex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ if eq site.Params.katex true }} 4 | 10 | 11 | 12 | 18 | 19 | 20 | 27 | {{ end }} 28 | -------------------------------------------------------------------------------- /layouts/partials/nav.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /layouts/shortcodes/bootstrap-card.html: -------------------------------------------------------------------------------- 1 | {{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get "img")) }} 2 | {{ $new := "" }} 3 | 4 | {{ if eq (.Get "command") "Fit" }} 5 | {{ $new = $original.Fit (.Get "options") }} 6 | {{ else if eq (.Get "command") "Resize" }} 7 | {{ $new = $original.Resize (.Get "options") }} 8 | {{ else if eq (.Get "command") "Fill" }} 9 | {{ $new = $original.Fill (.Get "options") }} 10 | {{ else }} 11 | {{ errorf "Invalid image processing command: Must be one of Fit, Fill, or Resize." }} 12 | {{ end }} 13 | 14 |
15 | 16 | {{ .Get 17 | 18 | {{ if or (.Get "title") (.Get "text") }} 19 |
20 | {{ with (.Get "title") }} 21 |
{{ . | markdownify }}
22 | {{ end }} 23 | {{ with (.Get "text") }} 24 |

{{ . | markdownify }}

25 | {{ end }} 26 |
27 | {{ end }} 28 |
-------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Zachary Betz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /layouts/partials/style.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exampleSite/config.yaml: -------------------------------------------------------------------------------- 1 | baseURL: https://example.com 2 | languageCode: en-us 3 | title: Vanilla 4 | theme: vanilla-bootstrap-hugo-theme 5 | googleAnalytics: UA-123456789-1 6 | 7 | taxonomies: 8 | tag: tags 9 | 10 | permalinks: 11 | post: /:filename/ 12 | 13 | # See https://feathericons.com/ 14 | # The value of pre is the icon name 15 | menu: 16 | nav: 17 | - name: Home 18 | pre: home 19 | url: / 20 | weight: 1 21 | - name: Blog 22 | pre: edit 23 | url: /post/ 24 | weight: 2 25 | - name: Tags 26 | pre: tag 27 | url: /tags/ 28 | weight: 3 29 | - name: About 30 | pre: smile 31 | url: /about/ 32 | weight: 4 33 | - name: RSS 34 | pre: rss 35 | url: /index.xml 36 | weight: 5 37 | 38 | params: 39 | includeBootstrapJs: false 40 | showActiveNav: true 41 | containerMaxWidth: 700px 42 | dateFormat: Jan 2, 2006 43 | homeText: Welcome to the Vanilla theme demo. Have a look around. Maybe even eat some ice cream. 44 | footerText: Made with [Hugo](https://gohugo.io/) & [Vanilla](https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme) 45 | hideFooter: false 46 | katex: true 47 | 48 | markup: 49 | defaultMarkdownHandler: goldmark 50 | goldmark: 51 | extensions: 52 | definitionList: true 53 | footnote: true 54 | linkify: true 55 | strikethrough: true 56 | table: true 57 | taskList: true 58 | typographer: true 59 | parser: 60 | attribute: true 61 | autoHeadingID: true 62 | renderer: 63 | hardWraps: false 64 | unsafe: true 65 | xHTML: false 66 | highlight: 67 | codeFences: true 68 | hl_Lines: "" 69 | lineNoStart: 1 70 | lineNos: false 71 | lineNumbersInTable: true 72 | noClasses: true 73 | style: monokai 74 | tabWidth: 4 75 | tableOfContents: 76 | endLevel: 6 77 | startLevel: 2 78 | -------------------------------------------------------------------------------- /exampleSite/content/post/style-a-markdown-table-with-bootstrap-classes-in-hugo.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: 2018-12-12T12:47:56-06:00 3 | tags: ["css", "bootstrap", "hugo"] 4 | title: "Style a markdown table with Bootstrap classes in Hugo" 5 | --- 6 | 7 | Inspired by [this discussion](https://discourse.gohugo.io/t/how-to-customise-tables/15661/), I wanted the ability to style a markdown table with [Bootstrap table classes](https://getbootstrap.com/docs/4.1/content/tables/). In the past, I've accomplished this by [defining the table in a data file](https://zwbetz.com/create-an-html-table-from-a-toml-data-file-in-hugo/), then building it with a shortcode. 8 | 9 | While this works fine, it's better for a different use case. I wanted something that meets the following criteria: 10 | 11 | - The table is defined in markdown 12 | - It lives in the content file, e.g. `content/post/some-post.md` 13 | - It's styled with Bootstrap table classes 14 | 15 | After a bit of tinkering, here's the shortcode I came up with. To use it, pass the markdown table between the shortcode, then pass the Bootstrap table classes as an argument. 16 | 17 | ## Usage 18 | 19 | ``` 20 | {{}} 21 | | Animal | Sounds | 22 | |---------|--------| 23 | | Cat | Meow | 24 | | Dog | Woof | 25 | | Cricket | Chirp | 26 | {{}} 27 | ``` 28 | 29 | ## Definition 30 | 31 | ``` 32 | {{ $htmlTable := .Inner | markdownify }} 33 | {{ $class := .Get 0 }} 34 | {{ $old := "
" }} 35 | {{ $new := printf "
" $class }} 36 | {{ $htmlTable := replace $htmlTable $old $new }} 37 | {{ $htmlTable | safeHTML }} 38 | ``` 39 | 40 | ## Output 41 | 42 | {{< bootstrap-table "table table-dark table-striped table-bordered" >}} 43 | | Animal | Sounds | 44 | |---------|--------| 45 | | Cat | Meow | 46 | | Dog | Woof | 47 | | Cricket | Chirp | 48 | {{< /bootstrap-table >}} -------------------------------------------------------------------------------- /exampleSite/content/post/nasa-images/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "NASA Images" 3 | date: 2018-12-27T20:46:49-06:00 4 | tags: ["nasa"] 5 | --- 6 | 7 | Images from the [NASA Image and Video Library](https://images.nasa.gov/). 8 | 9 | {{< bootstrap-card 10 | img="sun.jpg" 11 | title="The Sun" 12 | text="The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, with internal convective motion that generates a magnetic field via a dynamo process. It is by far the most important source of energy for life on Earth. [Credits](https://images.nasa.gov/details-GSFC_20171208_Archive_e000393.html)." 13 | alt="sun" 14 | command="Resize" 15 | options="700x" 16 | class="mb-3" >}} 17 | 18 | {{< bootstrap-card 19 | img="moon.jpg" 20 | title="The Moon" 21 | text="The Moon is an astronomical body that orbits planet Earth and is Earth's only permanent natural satellite. It is the fifth-largest natural satellite in the Solar System, and the largest among planetary satellites relative to the size of the planet that it orbits (its primary). The Moon is after Jupiter's satellite Io the second-densest satellite in the Solar System among those whose densities are known. [Credits](https://images.nasa.gov/details-GSFC_20171208_Archive_e001861.html)." 22 | alt="moon" 23 | command="Resize" 24 | options="700x" 25 | class="mb-3" >}} 26 | 27 | {{< bootstrap-card 28 | img="earth.jpg" 29 | title="The Earth" 30 | text="Earth is the third planet from the Sun and the only astronomical object known to harbor life. According to radiometric dating and other sources of evidence, Earth formed over 4.5 billion years ago. Earth's gravity interacts with other objects in space, especially the Sun and the Moon, Earth's only natural satellite. Earth revolves around the Sun in 365.26 days, a period known as an Earth year. During this time, Earth rotates about its axis about 366.26 times. [Credits](https://images.nasa.gov/details-PIA18033.html)." 31 | alt="earth" 32 | command="Resize" 33 | options="700x" 34 | class="mb-3" >}} 35 | -------------------------------------------------------------------------------- /exampleSite/content/post/quotes-by-carl-jung.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Quotes by Carl Jung" 3 | date: 2018-12-26T00:29:41-06:00 4 | tags: ["quotes"] 5 | --- 6 | 7 | {{< bootstrap-blockquote author="Carl Jung" >}} 8 | Even a happy life cannot be without a measure of darkness, and the word happy would lose its meaning if it were not balanced by sadness. It is far better to take things as they come along with patience and equanimity. 9 | {{< /bootstrap-blockquote >}} 10 | 11 | {{< bootstrap-blockquote author="Carl Jung" >}} 12 | The least of things with a meaning is worth more in life than the greatest of things without it. 13 | {{< /bootstrap-blockquote >}} 14 | 15 | {{< bootstrap-blockquote author="Carl Jung" >}} 16 | Who looks outside, dreams; who looks inside, awakes. 17 | {{< /bootstrap-blockquote >}} 18 | 19 | {{< bootstrap-blockquote author="Carl Jung" >}} 20 | Everything that irritates us about others can lead us to an understanding of ourselves. 21 | {{< /bootstrap-blockquote >}} 22 | 23 | {{< bootstrap-blockquote author="Carl Jung" >}} 24 | Knowing your own darkness is the best method for dealing with the darknesses of other people. 25 | {{< /bootstrap-blockquote >}} 26 | 27 | {{< bootstrap-blockquote author="Carl Jung" >}} 28 | The meeting of two personalities is like the contact of two chemical substances: if there is any reaction, both are transformed. 29 | {{< /bootstrap-blockquote >}} 30 | 31 | {{< bootstrap-blockquote author="Carl Jung" >}} 32 | There is no coming to consciousness without pain. 33 | {{< /bootstrap-blockquote >}} 34 | 35 | {{< bootstrap-blockquote author="Carl Jung" >}} 36 | As far as we can discern, the sole purpose of human existence is to kindle a light of meaning in the darkness of mere being. 37 | {{< /bootstrap-blockquote >}} 38 | 39 | {{< bootstrap-blockquote author="Carl Jung" >}} 40 | We cannot change anything until we accept it. Condemnation does not liberate, it oppresses. 41 | {{< /bootstrap-blockquote >}} 42 | 43 | {{< bootstrap-blockquote author="Carl Jung" >}} 44 | In all chaos there is a cosmos, in all disorder a secret order. 45 | {{< /bootstrap-blockquote >}} 46 | 47 | {{< bootstrap-blockquote author="Carl Jung" >}} 48 | Show me a sane man and I will cure him for you. 49 | {{< /bootstrap-blockquote >}} 50 | -------------------------------------------------------------------------------- /exampleSite/content/post/script-to-add-a-page-level-variable-to-content-front-matter-in-hugo.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2018-10-10" 3 | tags: ["hugo", "command-line", "awk"] 4 | title: "Script to add a page-level variable to content front matter in hugo" 5 | --- 6 | 7 | This was originally a question posed on the [hugo discussion forums](https://discourse.gohugo.io/t/set-frontmatter-params-in-list-template/14645). 8 | 9 | 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. 10 | 11 | She then wanted to `range` through her pages by their weight, like so: 12 | 13 | ```go 14 | {{ range .Pages.ByWeight }} 15 | 16 | {{ end }} 17 | ``` 18 | 19 | ## The script 20 | 21 | ```bash 22 | #!/bin/bash 23 | 24 | for file in *.md; do 25 | weight=${file:0:2} 26 | awk -v weight=$weight '/---/{ 27 | count++ 28 | if(count == 2){ 29 | sub("---","weight: " weight "\n---",$0) 30 | } 31 | } 32 | {print}' $file > tmp && mv tmp $file 33 | done 34 | ``` 35 | 36 | ## Explained 37 | 38 | Loop through all files in the directory with extension `.md`: 39 | 40 | ```bash 41 | for file in *.md; do 42 | # ... 43 | done 44 | ``` 45 | 46 | Set a variable using the first 2 characters of the filename: 47 | 48 | ```bash 49 | weight=${file:0:2} 50 | ``` 51 | 52 | Call an `awk` program and pass it a `weight` variable: 53 | 54 | ```bash 55 | awk -v weight=$weight 56 | ``` 57 | 58 | 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: 59 | 60 | ```bash 61 | '/---/{ 62 | count++ 63 | if(count == 2){ 64 | sub("---","weight: " weight "\n---",$0) 65 | } 66 | } 67 | {print}' 68 | ``` 69 | 70 | Redirect the output of the `awk` program to a tmp file, then overwrite the original content file with the tmp file: 71 | 72 | ```bash 73 | > tmp && mv tmp $file 74 | ``` 75 | 76 | ## Result 77 | 78 | Original `01_content.md`: 79 | 80 | ```yml 81 | --- 82 | title: "Some title" 83 | draft: false 84 | --- 85 | ``` 86 | 87 | Updated `01_content.md`: 88 | 89 | ```yml 90 | --- 91 | title: "Some title" 92 | draft: false 93 | weight: 01 94 | --- 95 | ``` -------------------------------------------------------------------------------- /exampleSite/content/post/use-snap-to-install-the-hugo-edge-version-on-fedora-and-ubuntu.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2018-10-26" 3 | tags: ["hugo", "snap", "fedora", "ubuntu"] 4 | title: "Use Snap to install the Hugo edge version on Fedora and Ubuntu" 5 | --- 6 | 7 | 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. 8 | 9 | ## Fedora-only steps 10 | 11 | To get started, [install Snap on Fedora](https://docs.snapcraft.io/installing-snap-on-fedora/6755): 12 | 13 | ``` 14 | sudo dnf install snapd 15 | ``` 16 | 17 | 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: 18 | 19 | ``` 20 | export PATH="$PATH:/var/lib/snapd/snap/bin" 21 | ``` 22 | 23 | ## Ubuntu-only steps 24 | 25 | 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: 26 | 27 | ``` 28 | sudo apt update && sudo apt install snapd 29 | ``` 30 | 31 | Check if the Snap directory is on your `PATH` by listing each entry: 32 | 33 | ``` 34 | echo $PATH | tr ':' '\n' 35 | ``` 36 | 37 | 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: 38 | 39 | ``` 40 | export PATH="$PATH:/snap/bin" 41 | ``` 42 | 43 | ## Install Hugo 44 | 45 | See which Snap channels are available for Hugo: 46 | 47 | ``` 48 | snap info hugo 49 | ``` 50 | 51 | Install Hugo from the edge channel: 52 | 53 | ``` 54 | sudo snap install hugo --channel=edge 55 | ``` 56 | 57 | Or, if you prefer Hugo Extended -- which has the [Hugo Pipes](https://gohugo.io/hugo-pipes/) feature -- install it from the extended edge channel: 58 | 59 | ``` 60 | sudo snap install hugo --channel=extended/edge 61 | ``` 62 | 63 | Lastly, confirm the location and version of Hugo that was intalled: 64 | 65 | ``` 66 | which hugo && hugo version 67 | ``` 68 | 69 | Happy testing :) 70 | 71 | ## Update or remove Hugo 72 | 73 | Snaps are [updated automatically](https://docs.snapcraft.io/keeping-snaps-up-to-date/7022). To manually update Hugo: 74 | 75 | ``` 76 | sudo snap refresh hugo 77 | ``` 78 | 79 | To remove Hugo: 80 | 81 | ``` 82 | sudo snap remove hugo 83 | ``` -------------------------------------------------------------------------------- /exampleSite/content/post/hugoisforlovers.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2014-04-02" 3 | tags: ["hugo", "git", "fun"] 4 | title: "Getting Started with Hugo" 5 | --- 6 | 7 | ## Step 1. Install Hugo 8 | 9 | Go to [Hugo releases](https://github.com/spf13/hugo/releases) and download the 10 | appropriate version for your OS and architecture. 11 | 12 | Save it somewhere specific as we will be using it in the next step. 13 | 14 | More complete instructions are available at [Install Hugo](https://gohugo.io/getting-started/installing/) 15 | 16 | ## Step 2. Build the Docs 17 | 18 | Hugo has its own example site which happens to also be the documentation site 19 | you are reading right now. 20 | 21 | Follow the following steps: 22 | 23 | 1. Clone the [Hugo repository](http://github.com/spf13/hugo) 24 | 2. Go into the repo 25 | 3. Run hugo in server mode and build the docs 26 | 4. Open your browser to http://localhost:1313 27 | 28 | Corresponding pseudo commands: 29 | 30 | git clone https://github.com/spf13/hugo 31 | cd hugo 32 | /path/to/where/you/installed/hugo server --source=./docs 33 | > 29 pages created 34 | > 0 tags index created 35 | > in 27 ms 36 | > Web Server is available at http://localhost:1313 37 | > Press ctrl+c to stop 38 | 39 | Once you've gotten here, follow along the rest of this page on your local build. 40 | 41 | ## Step 3. Change the docs site 42 | 43 | Stop the Hugo process by hitting Ctrl+C. 44 | 45 | Now we are going to run hugo again, but this time with hugo in watch mode. 46 | 47 | /path/to/hugo/from/step/1/hugo server --source=./docs --watch 48 | > 29 pages created 49 | > 0 tags index created 50 | > in 27 ms 51 | > Web Server is available at http://localhost:1313 52 | > Watching for changes in /Users/spf13/Code/hugo/docs/content 53 | > Press ctrl+c to stop 54 | 55 | 56 | Open your [favorite editor](http://vim.spf13.com) and change one of the source 57 | content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*. 58 | 59 | Content files are found in `docs/content/`. Unless otherwise specified, files 60 | are located at the same relative location as the url, in our case 61 | `docs/content/overview/quickstart.md`. 62 | 63 | Change and save this file.. Notice what happened in your terminal. 64 | 65 | > Change detected, rebuilding site 66 | 67 | > 29 pages created 68 | > 0 tags index created 69 | > in 26 ms 70 | 71 | Refresh the browser and observe that the typo is now fixed. 72 | 73 | Notice how quick that was. Try to refresh the site before it's finished building. I double dare you. 74 | Having nearly instant feedback enables you to have your creativity flow without waiting for long builds. 75 | 76 | ## Step 4. Have fun 77 | 78 | The best way to learn something is to play with it. 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ 2 | 3 | **WARNING:** This repo is no longer maintained. It's archived and read-only. 4 | 5 | ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ 6 | 7 | # Vanilla Bootstrap 8 | 9 | [![Netlify Status](https://api.netlify.com/api/v1/badges/c8f8a93c-33b9-48bc-b4d8-500c79b1b0ae/deploy-status)](https://app.netlify.com/sites/vanilla-bootstrap-hugo-theme/deploys) 10 | 11 | A vanilla [Bootstrap](https://getbootstrap.com/) theme for [Hugo](https://gohugo.io/). 12 | 13 | ## Table of Contents 14 | 15 | * [Demo](#demo) 16 | * [Minimum Hugo version](#minimum-hugo-version) 17 | * [Installation](#installation) 18 | * [Updating](#updating) 19 | * [Run example site](#run-example-site) 20 | * [Configuration](#configuration) 21 | * [Homepage content](#homepage-content) 22 | * [Shortcodes](#shortcodes) 23 | * [bootstrap-blockquote](#bootstrap-blockquote) 24 | * [bootstrap-table](#bootstrap-table) 25 | * [bootstrap-card](#bootstrap-card) 26 | * [Getting help](#getting-help) 27 | * [Credits](#credits) 28 | 29 | ## Demo 30 | 31 | https://vanilla-bootstrap-hugo-theme.netlify.com/ 32 | 33 | ## Minimum Hugo version 34 | 35 | Hugo version `0.81.0` or higher is required. View the [Hugo releases](https://github.com/gohugoio/hugo/releases) and download the binary for your OS. 36 | 37 | ## Installation 38 | 39 | From the root of your site: 40 | 41 | ``` 42 | git submodule add https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme.git themes/vanilla-bootstrap-hugo-theme 43 | ``` 44 | 45 | ## Updating 46 | 47 | From the root of your site: 48 | 49 | ``` 50 | git submodule update --remote --merge 51 | ``` 52 | 53 | ## Run example site 54 | 55 | From the root of `themes/vanilla-bootstrap-hugo-theme/exampleSite`: 56 | 57 | ``` 58 | hugo server --themesDir ../.. 59 | ``` 60 | 61 | ## Configuration 62 | 63 | Copy `config.yaml` from the [`exampleSite`](https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/tree/master/exampleSite), then edit as desired. 64 | 65 | ## Homepage content 66 | 67 | By default, the homepage uses the config file's `homeText` param for content. 68 | 69 | If you wish to provide content from a file, then create `content/_index.md` and it will be used instead. For example: 70 | 71 | ``` 72 | --- 73 | title: Home 74 | --- 75 | 76 | Homepage content goes here. 77 | ``` 78 | 79 | ## Shortcodes 80 | 81 | ### bootstrap-blockquote 82 | 83 | Uses [Bootstrap blockquotes](https://getbootstrap.com/docs/4.3/content/typography/#blockquotes) to format your blockquotes nicely. Pass the quote inside the shortcode. The `author` argument is optional. 84 | 85 | [Here's an actual usage](https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/master/exampleSite/content/post/quotes-by-carl-jung.md), and here's an example usage: 86 | 87 | ``` 88 | {{< bootstrap-blockquote author="Carl Jung" >}} 89 | Knowing your own darkness is the best method for dealing with the darknesses of other people. 90 | {{< /bootstrap-blockquote >}} 91 | ``` 92 | 93 | ### bootstrap-table 94 | 95 | Uses [Bootstrap tables](https://getbootstrap.com/docs/4.3/content/tables/) to format your tables nicely. Pass the markdown table inside the shortcode, then pass the classes as an argument. 96 | 97 | [Here's an actual usage](https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/master/exampleSite/content/post/style-a-markdown-table-with-bootstrap-classes-in-hugo.md), and here's an example usage: 98 | 99 | ``` 100 | {{< bootstrap-table "table table-dark table-striped table-bordered" >}} 101 | | Animal | Sounds | 102 | |---------|--------| 103 | | Cat | Meow | 104 | | Dog | Woof | 105 | | Cricket | Chirp | 106 | {{< /bootstrap-table >}} 107 | ``` 108 | 109 | ### bootstrap-card 110 | 111 | Uses [Bootstrap cards](https://getbootstrap.com/docs/4.3/components/card/) and [Hugo image processing](https://gohugo.io/content-management/image-processing/#readout) to display your [page bundle](https://gohugo.io/content-management/page-bundles/) images nicely. Only the `img`, `command`, and `options` arguments are required. 112 | 113 | [Here's an actual usage](https://raw.githubusercontent.com/zwbetz-gh/vanilla-bootstrap-hugo-theme/master/exampleSite/content/post/nasa-images/index.md), and here's an example usage: 114 | 115 | ``` 116 | {{< bootstrap-card 117 | img="sun.jpg" 118 | command="Resize" 119 | options="700x" 120 | title="The Sun" 121 | text="The Sun is the star at the center of the Solar System." 122 | alt="sun" 123 | class="mb-3" 124 | style="" >}} 125 | ``` 126 | 127 | ## Getting help 128 | 129 | If you run into an issue that isn't answered by this documentation or the [`exampleSite`](https://github.com/zwbetz-gh/vanilla-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). 130 | 131 | ## Credits 132 | 133 | In addition to Bootstrap and Hugo, thank you to: 134 | 135 | * [Feather](https://feathericons.com/) for icons 136 | * [Netlify](https://www.netlify.com/) for deploys 137 | * [gh-md-toc](https://github.com/ekalinin/github-markdown-toc) for toc generation 138 | * [vscode](https://code.visualstudio.com/) for text editing 139 | * [Fedora](https://getfedora.org/), [Xfce](https://www.xfce.org/), and [VirtualBox](https://www.virtualbox.org/) for development environment 140 | * [befunky](https://www.befunky.com/) for screenshot editing 141 | * [Freepik](https://www.freepik.com/) and [Flaticon](https://www.flaticon.com/) for favicon 142 | -------------------------------------------------------------------------------- /exampleSite/content/post/migrate-from-jekyll.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2014-03-10" 3 | draft: false 4 | lastmod: "2014-03-10" 5 | publishdate: "2014-03-10" 6 | tags: 7 | - hugo 8 | - jekyll 9 | - migration 10 | - git 11 | - templates 12 | title: Migrate to Hugo from Jekyll 13 | --- 14 | 15 | ## Move static content to `static` 16 | 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. 17 | With Jekyll, something that looked like 18 | 19 | ▾ / 20 | ▾ images/ 21 | logo.png 22 | 23 | should become 24 | 25 | ▾ / 26 | ▾ static/ 27 | ▾ images/ 28 | logo.png 29 | 30 | Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`. 31 | 32 | ## Create your Hugo configuration file 33 | 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. 34 | 35 | ## Set your configuration publish folder to `_site` 36 | 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: 37 | 38 | 1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended). 39 | 40 | git submodule deinit _site 41 | git rm _site 42 | git submodule add -b gh-pages git@github.com:your-username/your-repo.git public 43 | 44 | 2. Or, change the Hugo configuration to use `_site` instead of `public`. 45 | 46 | { 47 | .. 48 | "publishdir": "_site", 49 | .. 50 | } 51 | 52 | ## Convert Jekyll templates to Hugo templates 53 | 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. 54 | 55 | As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours. 56 | 57 | ## Convert Jekyll plugins to Hugo shortcodes 58 | Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port. 59 | 60 | ### Implementation 61 | 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. 62 | 63 | Jekyll's plugin: 64 | 65 | module Jekyll 66 | class ImageTag < Liquid::Tag 67 | @url = nil 68 | @caption = nil 69 | @class = nil 70 | @link = nil 71 | // Patterns 72 | IMAGE_URL_WITH_CLASS_AND_CAPTION = 73 | IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i 74 | IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i 75 | IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i 76 | IMAGE_URL = /((https?:\/\/|\/)(\S+))/i 77 | def initialize(tag_name, markup, tokens) 78 | super 79 | if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK 80 | @class = $1 81 | @url = $3 82 | @caption = $7 83 | @link = $9 84 | elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION 85 | @class = $1 86 | @url = $3 87 | @caption = $7 88 | elsif markup =~ IMAGE_URL_WITH_CAPTION 89 | @url = $1 90 | @caption = $5 91 | elsif markup =~ IMAGE_URL_WITH_CLASS 92 | @class = $1 93 | @url = $3 94 | elsif markup =~ IMAGE_URL 95 | @url = $1 96 | end 97 | end 98 | def render(context) 99 | if @class 100 | source = "
" 101 | else 102 | source = "
" 103 | end 104 | if @link 105 | source += "" 106 | end 107 | source += "" 108 | if @link 109 | source += "" 110 | end 111 | source += "
#{@caption}
" if @caption 112 | source += "
" 113 | source 114 | end 115 | end 116 | end 117 | Liquid::Template.register_tag('image', Jekyll::ImageTag) 118 | 119 | is written as this Hugo shortcode: 120 | 121 | 122 |
123 | {{ with .Get "link"}}{{ end }} 124 | 125 | {{ if .Get "link"}}{{ end }} 126 | {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} 127 |
{{ if isset .Params "title" }} 128 | {{ .Get "title" }}{{ end }} 129 | {{ if or (.Get "caption") (.Get "attr")}}

130 | {{ .Get "caption" }} 131 | {{ with .Get "attrlink"}} {{ end }} 132 | {{ .Get "attr" }} 133 | {{ if .Get "attrlink"}} {{ end }} 134 |

{{ end }} 135 |
136 | {{ end }} 137 |
138 | 139 | 140 | ### Usage 141 | I simply changed: 142 | 143 | {% 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/ %} 144 | 145 | to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`): 146 | 147 | {{%/* 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/" */%}} 148 | 149 | As a bonus, the shortcode named parameters are, arguably, more readable. 150 | 151 | ## Finishing touches 152 | ### Fix content 153 | 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. 154 | 155 | ### Clean up 156 | You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it. 157 | 158 | ## A practical example in a diff 159 | [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). 160 | -------------------------------------------------------------------------------- /gh-md-toc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Steps: 5 | # 6 | # 1. Download corresponding html file for some README.md: 7 | # curl -s $1 8 | # 9 | # 2. Discard rows where no substring 'user-content-' (github's markup): 10 | # awk '/user-content-/ { ... 11 | # 12 | # 3.1 Get last number in each row like ' ... sitemap.js.*<\/h/)+2, RLENGTH-5) 21 | # 22 | # 5. Find anchor and insert it inside "(...)": 23 | # substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) 24 | # 25 | 26 | gh_toc_version="0.5.0" 27 | 28 | gh_user_agent="gh-md-toc v$gh_toc_version" 29 | 30 | # 31 | # Download rendered into html README.md by its url. 32 | # 33 | # 34 | gh_toc_load() { 35 | local gh_url=$1 36 | 37 | if type curl &>/dev/null; then 38 | curl --user-agent "$gh_user_agent" -s "$gh_url" 39 | elif type wget &>/dev/null; then 40 | wget --user-agent="$gh_user_agent" -qO- "$gh_url" 41 | else 42 | echo "Please, install 'curl' or 'wget' and try again." 43 | exit 1 44 | fi 45 | } 46 | 47 | # 48 | # Converts local md file into html by GitHub 49 | # 50 | # ➥ curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown 51 | #

Hello world github/linguist#1 cool, and #1!

'" 52 | gh_toc_md2html() { 53 | local gh_file_md=$1 54 | URL=https://api.github.com/markdown/raw 55 | TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" 56 | if [ -f "$TOKEN" ]; then 57 | URL="$URL?access_token=$(cat $TOKEN)" 58 | fi 59 | OUTPUT="$(curl -s --user-agent "$gh_user_agent" \ 60 | --data-binary @"$gh_file_md" -H "Content-Type:text/plain" \ 61 | $URL)" 62 | 63 | if [ "$?" != "0" ]; then 64 | echo "XXNetworkErrorXX" 65 | fi 66 | if [ "$(echo "${OUTPUT}" | awk '/API rate limit exceeded/')" != "" ]; then 67 | echo "XXRateLimitXX" 68 | else 69 | echo "${OUTPUT}" 70 | fi 71 | } 72 | 73 | 74 | # 75 | # Is passed string url 76 | # 77 | gh_is_url() { 78 | case $1 in 79 | https* | http*) 80 | echo "yes";; 81 | *) 82 | echo "no";; 83 | esac 84 | } 85 | 86 | # 87 | # TOC generator 88 | # 89 | gh_toc(){ 90 | local gh_src=$1 91 | local gh_src_copy=$1 92 | local gh_ttl_docs=$2 93 | local need_replace=$3 94 | 95 | if [ "$gh_src" = "" ]; then 96 | echo "Please, enter URL or local path for a README.md" 97 | exit 1 98 | fi 99 | 100 | 101 | # Show "TOC" string only if working with one document 102 | if [ "$gh_ttl_docs" = "1" ]; then 103 | 104 | echo "Table of Contents" 105 | echo "=================" 106 | echo "" 107 | gh_src_copy="" 108 | 109 | fi 110 | 111 | if [ "$(gh_is_url "$gh_src")" == "yes" ]; then 112 | gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" 113 | if [ "${PIPESTATUS[0]}" != "0" ]; then 114 | echo "Could not load remote document." 115 | echo "Please check your url or network connectivity" 116 | exit 1 117 | fi 118 | if [ "$need_replace" = "yes" ]; then 119 | echo 120 | echo "!! '$gh_src' is not a local file" 121 | echo "!! Can't insert the TOC into it." 122 | echo 123 | fi 124 | else 125 | local rawhtml=$(gh_toc_md2html "$gh_src") 126 | if [ "$rawhtml" == "XXNetworkErrorXX" ]; then 127 | echo "Parsing local markdown file requires access to github API" 128 | echo "Please make sure curl is installed and check your network connectivity" 129 | exit 1 130 | fi 131 | if [ "$rawhtml" == "XXRateLimitXX" ]; then 132 | echo "Parsing local markdown file requires access to github API" 133 | echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting" 134 | TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" 135 | echo "or place github auth token here: $TOKEN" 136 | exit 1 137 | fi 138 | local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy"` 139 | echo "$toc" 140 | if [ "$need_replace" = "yes" ]; then 141 | local ts="<\!--ts-->" 142 | local te="<\!--te-->" 143 | local dt=`date +'%F_%H%M%S'` 144 | local ext=".orig.${dt}" 145 | local toc_path="${gh_src}.toc.${dt}" 146 | local toc_footer="" 147 | # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html 148 | # clear old TOC 149 | sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src" 150 | # create toc file 151 | echo "${toc}" > "${toc_path}" 152 | echo -e "\n${toc_footer}\n" >> "$toc_path" 153 | # insert toc file 154 | if [[ "`uname`" == "Darwin" ]]; then 155 | sed -i "" "/${ts}/r ${toc_path}" "$gh_src" 156 | else 157 | sed -i "/${ts}/r ${toc_path}" "$gh_src" 158 | fi 159 | echo 160 | echo "!! TOC was added into: '$gh_src'" 161 | echo "!! Origin version of the file: '${gh_src}${ext}'" 162 | echo "!! TOC added into a separate file: '${toc_path}'" 163 | echo 164 | fi 165 | fi 166 | } 167 | 168 | # 169 | # Grabber of the TOC from rendered html 170 | # 171 | # $1 — a source url of document. 172 | # It's need if TOC is generated for multiple documents. 173 | # 174 | gh_toc_grab() { 175 | # if closed is on the new line, then move it on the prev line 176 | # for example: 177 | # was: The command foo1 178 | # 179 | # became: The command foo1 180 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' | 181 | # find strings that corresponds to template 182 | grep -E -o '//' | sed 's/<\/code>//' | 185 | # now all rows are like: 186 | # ... .*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')" 191 | } 192 | 193 | # 194 | # Returns filename only from full path or url 195 | # 196 | gh_toc_get_filename() { 197 | echo "${1##*/}" 198 | } 199 | 200 | # 201 | # Options hendlers 202 | # 203 | gh_toc_app() { 204 | local app_name=$(basename $0) 205 | local need_replace="no" 206 | 207 | if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then 208 | echo "GitHub TOC generator ($app_name): $gh_toc_version" 209 | echo "" 210 | echo "Usage:" 211 | echo " $app_name [--insert] src [src] Create TOC for a README file (url or local path)" 212 | echo " $app_name - Create TOC for markdown from STDIN" 213 | echo " $app_name --help Show help" 214 | echo " $app_name --version Show version" 215 | return 216 | fi 217 | 218 | if [ "$1" = '--version' ]; then 219 | echo "$gh_toc_version" 220 | return 221 | fi 222 | 223 | if [ "$1" = "-" ]; then 224 | if [ -z "$TMPDIR" ]; then 225 | TMPDIR="/tmp" 226 | elif [ -n "$TMPDIR" -a ! -d "$TMPDIR" ]; then 227 | mkdir -p "$TMPDIR" 228 | fi 229 | local gh_tmp_md 230 | gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX) 231 | while read input; do 232 | echo "$input" >> "$gh_tmp_md" 233 | done 234 | gh_toc_md2html "$gh_tmp_md" | gh_toc_grab "" 235 | return 236 | fi 237 | 238 | if [ "$1" = '--insert' ]; then 239 | need_replace="yes" 240 | shift 241 | fi 242 | 243 | for md in "$@" 244 | do 245 | echo "" 246 | gh_toc "$md" "$#" "$need_replace" 247 | done 248 | 249 | echo "" 250 | echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)" 251 | } 252 | 253 | # 254 | # Entry point 255 | # 256 | gh_toc_app "$@" -------------------------------------------------------------------------------- /exampleSite/content/post/goisforlovers.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: "2014-04-02" 3 | tags: ["go", "templates", "hugo"] 4 | title: "(Hu)go Template Primer" 5 | --- 6 | 7 | Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for 8 | its template engine. It is an extremely lightweight engine that provides a very 9 | small amount of logic. In our experience that it is just the right amount of 10 | logic to be able to create a good static website. If you have used other 11 | template systems from different languages or frameworks you will find a lot of 12 | similarities in Go templates. 13 | 14 | This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate] 15 | provide more details. 16 | 17 | ## Introduction to Go Templates 18 | 19 | Go templates provide an extremely simple template language. It adheres to the 20 | belief that only the most basic of logic belongs in the template or view layer. 21 | One consequence of this simplicity is that Go templates parse very quickly. 22 | 23 | A unique characteristic of Go templates is they are content aware. Variables and 24 | content will be sanitized depending on the context of where they are used. More 25 | details can be found in the [Go docs][gohtmltemplate]. 26 | 27 | ## Basic Syntax 28 | 29 | Golang templates are HTML files with the addition of variables and 30 | functions. 31 | 32 | **Go variables and functions are accessible within {{ }}** 33 | 34 | Accessing a predefined variable "foo": 35 | 36 | {{ foo }} 37 | 38 | **Parameters are separated using spaces** 39 | 40 | Calling the add function with input of 1, 2: 41 | 42 | {{ add 1 2 }} 43 | 44 | **Methods and fields are accessed via dot notation** 45 | 46 | Accessing the Page Parameter "bar" 47 | 48 | {{ .Params.bar }} 49 | 50 | **Parentheses can be used to group items together** 51 | 52 | {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }} 53 | 54 | 55 | ## Variables 56 | 57 | Each Go template has a struct (object) made available to it. In hugo each 58 | template is passed either a page or a node struct depending on which type of 59 | page you are rendering. More details are available on the 60 | [variables](/layout/variables) page. 61 | 62 | A variable is accessed by referencing the variable name. 63 | 64 | {{ .Title }} 65 | 66 | Variables can also be defined and referenced. 67 | 68 | {{ $address := "123 Main St."}} 69 | {{ $address }} 70 | 71 | 72 | ## Functions 73 | 74 | Go template ship with a few functions which provide basic functionality. The Go 75 | template system also provides a mechanism for applications to extend the 76 | available functions with their own. [Hugo template 77 | functions](/layout/functions) provide some additional functionality we believe 78 | are useful for building websites. Functions are called by using their name 79 | followed by the required parameters separated by spaces. Template 80 | functions cannot be added without recompiling hugo. 81 | 82 | **Example:** 83 | 84 | {{ add 1 2 }} 85 | 86 | ## Includes 87 | 88 | When including another template you will pass to it the data it will be 89 | able to access. To pass along the current context please remember to 90 | include a trailing dot. The templates location will always be starting at 91 | the /layout/ directory within Hugo. 92 | 93 | **Example:** 94 | 95 | {{ template "chrome/header.html" . }} 96 | 97 | 98 | ## Logic 99 | 100 | Go templates provide the most basic iteration and conditional logic. 101 | 102 | ### Iteration 103 | 104 | Just like in Go, the Go templates make heavy use of range to iterate over 105 | a map, array or slice. The following are different examples of how to use 106 | range. 107 | 108 | **Example 1: Using Context** 109 | 110 | {{ range array }} 111 | {{ . }} 112 | {{ end }} 113 | 114 | **Example 2: Declaring value variable name** 115 | 116 | {{range $element := array}} 117 | {{ $element }} 118 | {{ end }} 119 | 120 | **Example 2: Declaring key and value variable name** 121 | 122 | {{range $index, $element := array}} 123 | {{ $index }} 124 | {{ $element }} 125 | {{ end }} 126 | 127 | ### Conditionals 128 | 129 | If, else, with, or, & and provide the framework for handling conditional 130 | logic in Go Templates. Like range, each statement is closed with `end`. 131 | 132 | 133 | Go Templates treat the following values as false: 134 | 135 | * false 136 | * 0 137 | * any array, slice, map, or string of length zero 138 | 139 | **Example 1: If** 140 | 141 | {{ if isset .Params "title" }}

{{ index .Params "title" }}

{{ end }} 142 | 143 | **Example 2: If -> Else** 144 | 145 | {{ if isset .Params "alt" }} 146 | {{ index .Params "alt" }} 147 | {{else}} 148 | {{ index .Params "caption" }} 149 | {{ end }} 150 | 151 | **Example 3: And & Or** 152 | 153 | {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} 154 | 155 | **Example 4: With** 156 | 157 | An alternative way of writing "if" and then referencing the same value 158 | is to use "with" instead. With rebinds the context `.` within its scope, 159 | and skips the block if the variable is absent. 160 | 161 | The first example above could be simplified as: 162 | 163 | {{ with .Params.title }}

{{ . }}

{{ end }} 164 | 165 | **Example 5: If -> Else If** 166 | 167 | {{ if isset .Params "alt" }} 168 | {{ index .Params "alt" }} 169 | {{ else if isset .Params "caption" }} 170 | {{ index .Params "caption" }} 171 | {{ end }} 172 | 173 | ## Pipes 174 | 175 | One of the most powerful components of Go templates is the ability to 176 | stack actions one after another. This is done by using pipes. Borrowed 177 | from unix pipes, the concept is simple, each pipeline's output becomes the 178 | input of the following pipe. 179 | 180 | Because of the very simple syntax of Go templates, the pipe is essential 181 | to being able to chain together function calls. One limitation of the 182 | pipes is that they only can work with a single value and that value 183 | becomes the last parameter of the next pipeline. 184 | 185 | A few simple examples should help convey how to use the pipe. 186 | 187 | **Example 1 :** 188 | 189 | {{ if eq 1 1 }} Same {{ end }} 190 | 191 | is the same as 192 | 193 | {{ eq 1 1 | if }} Same {{ end }} 194 | 195 | It does look odd to place the if at the end, but it does provide a good 196 | illustration of how to use the pipes. 197 | 198 | **Example 2 :** 199 | 200 | {{ index .Params "disqus_url" | html }} 201 | 202 | Access the page parameter called "disqus_url" and escape the HTML. 203 | 204 | **Example 3 :** 205 | 206 | {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} 207 | Stuff Here 208 | {{ end }} 209 | 210 | Could be rewritten as 211 | 212 | {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }} 213 | Stuff Here 214 | {{ end }} 215 | 216 | 217 | ## Context (aka. the dot) 218 | 219 | The most easily overlooked concept to understand about Go templates is that {{ . }} 220 | always refers to the current context. In the top level of your template this 221 | will be the data set made available to it. Inside of a iteration it will have 222 | the value of the current item. When inside of a loop the context has changed. . 223 | will no longer refer to the data available to the entire page. If you need to 224 | access this from within the loop you will likely want to set it to a variable 225 | instead of depending on the context. 226 | 227 | **Example:** 228 | 229 | {{ $title := .Site.Title }} 230 | {{ range .Params.tags }} 231 |
  • {{ . }} - {{ $title }}
  • 232 | {{ end }} 233 | 234 | Notice how once we have entered the loop the value of {{ . }} has changed. We 235 | have defined a variable outside of the loop so we have access to it from within 236 | the loop. 237 | 238 | # Hugo Parameters 239 | 240 | Hugo provides the option of passing values to the template language 241 | through the site configuration (for sitewide values), or through the meta 242 | data of each specific piece of content. You can define any values of any 243 | type (supported by your front matter/config format) and use them however 244 | you want to inside of your templates. 245 | 246 | 247 | ## Using Content (page) Parameters 248 | 249 | In each piece of content you can provide variables to be used by the 250 | templates. This happens in the [front matter](/content/front-matter). 251 | 252 | An example of this is used in this documentation site. Most of the pages 253 | benefit from having the table of contents provided. Sometimes the TOC just 254 | doesn't make a lot of sense. We've defined a variable in our front matter 255 | of some pages to turn off the TOC from being displayed. 256 | 257 | Here is the example front matter: 258 | 259 | ``` 260 | --- 261 | title: "Permalinks" 262 | date: "2013-11-18" 263 | aliases: 264 | - "/doc/permalinks/" 265 | groups: ["extras"] 266 | groups_weight: 30 267 | notoc: true 268 | --- 269 | ``` 270 | 271 | Here is the corresponding code inside of the template: 272 | 273 | {{ if not .Params.notoc }} 274 |
    275 | {{ .TableOfContents }} 276 |
    277 | {{ end }} 278 | 279 | 280 | 281 | ## Using Site (config) Parameters 282 | In your top-level configuration file (eg, `config.yaml`) you can define site 283 | parameters, which are values which will be available to you in chrome. 284 | 285 | For instance, you might declare: 286 | 287 | ```yaml 288 | params: 289 | CopyrightHTML: "Copyright © 2013 John Doe. All Rights Reserved." 290 | TwitterUser: "spf13" 291 | SidebarRecentLimit: 5 292 | ``` 293 | 294 | Within a footer layout, you might then declare a `