├── exampleSite ├── static │ └── .gitkeep ├── data │ └── l10n.toml ├── config.toml └── content │ └── post │ ├── hugo-is-for-lovers.md │ ├── migrate-from-jekyll.md │ ├── go-is-for-lovers.md │ └── creating-a-new-theme.md ├── archetypes └── default.md ├── images ├── tn.png └── screenshot.png ├── layouts ├── index.html ├── _default │ ├── summary.html │ ├── list.html │ ├── terms.html │ └── single.html ├── partials │ ├── article-list.html │ ├── author.html │ ├── article-header.html │ ├── pagination.html │ ├── footer.html │ ├── article-share.html │ ├── social.html │ └── header.html └── 404.html ├── static ├── favicon.ico ├── img │ ├── desk.jpg │ └── profile-image.png ├── font │ ├── fontello.eot │ ├── fontello.ttf │ ├── fontello.woff │ └── fontello.svg ├── apple-touch-icon.png ├── js │ ├── plugins.js │ └── vendor │ │ └── modernizr-2.8.0.min.js └── css │ ├── highlightjs │ └── monokai.css │ └── styles.css ├── theme.toml ├── CHANGELOG.md ├── README.md └── LICENSE.md /exampleSite/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /archetypes/default.md: -------------------------------------------------------------------------------- 1 | +++ 2 | tags = [] 3 | +++ 4 | -------------------------------------------------------------------------------- /images/tn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/images/tn.png -------------------------------------------------------------------------------- /layouts/index.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 | {{ partial "article-list" . }} 3 | {{ partial "footer" . }} 4 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/favicon.ico -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/images/screenshot.png -------------------------------------------------------------------------------- /static/img/desk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/img/desk.jpg -------------------------------------------------------------------------------- /static/font/fontello.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/font/fontello.eot -------------------------------------------------------------------------------- /static/font/fontello.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/font/fontello.ttf -------------------------------------------------------------------------------- /static/font/fontello.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/font/fontello.woff -------------------------------------------------------------------------------- /static/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/apple-touch-icon.png -------------------------------------------------------------------------------- /static/img/profile-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/static/img/profile-image.png -------------------------------------------------------------------------------- /layouts/_default/summary.html: -------------------------------------------------------------------------------- 1 |
2 | {{ partial "article-header" . }} 3 |

{{ printf "%s" .Summary | markdownify }}…

4 | {{ .Site.Data.l10n.article.read_more }} » 5 |
6 | -------------------------------------------------------------------------------- /layouts/partials/article-list.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" site.Params.mainSections) }} 4 | {{ range $paginator.Pages }} 5 | {{ .Render "summary" }} 6 | {{ end }} 7 | {{ partial "pagination" . }} 8 |
9 | 10 | {{ partial "author" . }} 11 |
12 | -------------------------------------------------------------------------------- /layouts/partials/author.html: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /layouts/404.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 |
3 |
4 | « {{ .Site.Data.l10n.article.back_to_home }} 5 |

{{ .Site.Data.l10n.page_not_found.title }}

6 |

{{ .Site.Data.l10n.page_not_found.subtitle }}

7 |
8 | {{ partial "author" . }} 9 |
10 | {{ partial "footer" . }} 11 | -------------------------------------------------------------------------------- /layouts/_default/list.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 |
3 |
4 | « {{ .Site.Data.l10n.article.back_to_home }} 5 | {{ $paginator := .Paginate .Data.Pages }} 6 | {{ range $paginator.Pages }} 7 | {{ .Render "summary" }} 8 | {{ end }} 9 | {{ partial "pagination" . }} 10 |
11 | 12 | {{ partial "author" . }} 13 |
14 | {{ partial "footer" . }} 15 | -------------------------------------------------------------------------------- /layouts/_default/terms.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 |
3 |
4 | « {{ .Site.Data.l10n.article.back_to_home }} 5 |

{{ .Title }}: 6 | 13 |

14 | {{ partial "author" . }} 15 |
16 | {{ partial "footer" . }} 17 | -------------------------------------------------------------------------------- /theme.toml: -------------------------------------------------------------------------------- 1 | name = "Minimalist" 2 | license = "Apache License 2.0" 3 | licenselink = "https://github.com/digitalcraftsman/hugo-minimalist-theme/blob/master/LICENSE.md" 4 | description = "A minimalistic theme with the focus on blogging." 5 | homepage = "https://github.com/digitalcraftsman" 6 | tags = ["disqus", "google analytics", "responsive", "syntax highlighting", "l10n"] 7 | features = [] 8 | min_version = "0.57.2" 9 | 10 | [author] 11 | name = "Digitalcraftsman" 12 | homepage = "https://github.com/digitalcraftsman" 13 | 14 | # If porting an existing theme 15 | [original] 16 | name = "Raphael Riegger" 17 | homepage = "http://rriegger.com/" 18 | repo = "https://github.com/rriegger/MinimalisticBlogTheme" 19 | -------------------------------------------------------------------------------- /exampleSite/data/l10n.toml: -------------------------------------------------------------------------------- 1 | [author] 2 | by = "by" 3 | 4 | [article] 5 | read_more = "Read more" 6 | back_to_home = "Back to home" 7 | posted_on = "Posted on" 8 | tagged_in = "Tagged in" 9 | 10 | [comments] 11 | comments = "Comments" 12 | 13 | [share] 14 | title = "Share this article:" 15 | facebook = "Share on Facebook" 16 | twitter = "Tweet this article" 17 | gplus = "Share on Google+" 18 | linkedin = "Share on Linkedin" 19 | 20 | [pagination] 21 | newer = "Newer" 22 | older = "Older" 23 | # Page x of y 24 | page = "Page" 25 | of = "of" 26 | 27 | [page_not_found] 28 | title = "404 - page not found" 29 | subtitle = "The content you're looking for doesn't seem to exist." 30 | -------------------------------------------------------------------------------- /layouts/partials/article-header.html: -------------------------------------------------------------------------------- 1 | {{ if .IsPage }} 2 |

{{ .Title }}

3 | {{ else }} 4 |

{{ .Title }}

5 | {{ end }} 6 | 16 | -------------------------------------------------------------------------------- /layouts/partials/pagination.html: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /layouts/_default/single.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 | 3 |
4 |
5 | 11 | {{ if .Site.DisqusShortname }} 12 |
13 |

{{ .Site.Data.l10n.comments.comments }}

14 | {{ template "_internal/disqus.html" . }} 15 |
16 | {{ end }} 17 |
18 | {{ partial "author" . }} 19 |
20 | 21 | {{ partial "footer" . }} 22 | -------------------------------------------------------------------------------- /static/js/plugins.js: -------------------------------------------------------------------------------- 1 | // Avoid `console` errors in browsers that lack a console. 2 | (function() { 3 | var method; 4 | var noop = function () {}; 5 | var methods = [ 6 | 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 7 | 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 8 | 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 9 | 'timeStamp', 'trace', 'warn' 10 | ]; 11 | var length = methods.length; 12 | var console = (window.console = window.console || {}); 13 | 14 | while (length--) { 15 | method = methods[length]; 16 | 17 | // Only stub undefined methods. 18 | if (!console[method]) { 19 | console[method] = noop; 20 | } 21 | } 22 | }()); 23 | 24 | // Place any jQuery/helper plugins in here. 25 | -------------------------------------------------------------------------------- /layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{ range .Site.Params.custom_js }} 15 | 16 | {{ end }} 17 | 18 | {{ template "_internal/google_analytics.html" . }} 19 | 20 | 21 | -------------------------------------------------------------------------------- /layouts/partials/article-share.html: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /layouts/partials/social.html: -------------------------------------------------------------------------------- 1 | {{ with .Site.Social.twitter }} 2 |
  • 3 | {{ end }} 4 | 5 | {{ with .Site.Social.facebook }} 6 |
  • 7 | {{ end }} 8 | 9 | {{ with .Site.Social.linkedin }} 10 |
  • 11 | {{ end }} 12 | 13 | {{ with .Site.Social.behance }} 14 |
  • 15 | {{ end }} 16 | 17 | {{ with .Site.Social.dribbble }} 18 |
  • 19 | {{ end }} 20 | 21 | {{ with .Site.Social.instagram }} 22 |
  • 23 | {{ end }} 24 | 25 | {{ with .Site.Social.github }} 26 |
  • 27 | {{ end }} 28 | 29 | {{ with .Site.Social.gplus }} 30 |
  • 31 | {{ end }} 32 | 33 |
  • 34 | -------------------------------------------------------------------------------- /exampleSite/config.toml: -------------------------------------------------------------------------------- 1 | baseurl = "https://example.org/" 2 | languageCode = "en-us" 3 | title = "John Doe's blog" 4 | # Define how many pages appear per site 5 | paginate = 10 6 | # Enable comments powered by Disqus by entering your disqus shortname 7 | disqusShortname = "spf13" 8 | # Enable gogle analytics by entering your tracking code 9 | googleAnalytics = "" 10 | theme = "hugo-minimalist-theme" 11 | # Remove this line if you use this theme for a real website. 12 | # It allows you to preview the theme within the exampleSite folder 13 | # with the hugo server command 14 | themesDir = "../.." 15 | 16 | [params] 17 | site_author = "John Doe" 18 | site_description = "The awesome blog of John Doe." 19 | location = "Earth" 20 | # Link custom assets relative to /static 21 | avatar = "img/profile-image.png" 22 | header_background = "img/desk.jpg" 23 | header_title = "Customizable header title" 24 | copyright = "Powered by [Hugo](http://gohugo.io)." 25 | custom_css = [] 26 | custom_js = [] 27 | 28 | # Define which content types are shown on the homepage 29 | mainSections = ["post"] 30 | 31 | # Enable gogle analytics by entering your tracking code 32 | google_analytics = "" 33 | 34 | [social] 35 | # Add your social network accounts to the profile section on the left 36 | # by entering your username. The links to your account will be 37 | # create automatically. 38 | twitter = "spf13" 39 | facebook = "" 40 | linkedin = "" 41 | behance = "" 42 | dribbble = "" 43 | instagram = "" 44 | github = "digitalcraftsman" 45 | gplus = "" 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### 30th September 2019 4 | 5 | **Note: due to deprecation and addtion of certain Hugo features and variables the required minumum version of Hugo is now `0.57.2`** 6 | 7 | `.Site.RegularPages` in combination with `.Site.Params.mainSections` is used to define the kind of content shown on the homepage ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/92891fe6186515ade4c18bde12bee53b6aef7c0d)). This is a more flexible approach than hard-coding the `post` content type. Add the following lines to your config file to restore the old behavior (TOML version): 8 | 9 | ```toml 10 | [params] 11 | mainSections = ["post"] 12 | ``` 13 | 14 | Furthermore, all instances of the `.Hugo` template variable have been replaced with the `hugo` template function ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/561374e3bb98d234f0ced7dd34e28d68e016f3b7)). RSS feeds are now included using Hugo's `OutputFormats` feature ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/ee4a1be11e060e69f40f340eff11b95d9be0a0ce)). 15 | 16 | ### 21st December 2016 17 | 18 | Custom assets can now be linked with the `custom_js` and `custom_css` variables ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/d084de82d969d36b38765f5499a3a558f475182e)) 19 | 20 | The `exampleSite` folder is now a standalone Hugo website that can be used to preview the theme. Make sure you change the `themesDir` variable in the config file as described in the "Installation" section of the README ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/d084de82d969d36b38765f5499a3a558f475182e)) 21 | 22 | Now, this theme makes use of Hugo's own Google Analytics template ([show diff](https://github.com/digitalcraftsman/hugo-minimalist-theme/commit/4e2916a4bc11ce3191dd325e17237a25d01f5b58)). You have to move your tracking code in the config file as follows: 23 | 24 | ```toml 25 | # Remove 26 | [params] 27 | google_analytics = "" 28 | 29 | # and add outside the params block 30 | googleAnalytics = "" 31 | ``` -------------------------------------------------------------------------------- /layouts/partials/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ if .IsNode}}{{ .Title }} · {{end}}{{ .Site.Title }} 7 | 8 | 9 | 10 | {{ hugo.Generator }} 11 | {{ with .OutputFormats.Get "RSS" }} 12 | 13 | 14 | {{ end }} 15 | 16 | 17 | 18 | 19 | 20 | 21 | {{ range .Site.Params.custom_css }} 22 | 23 | {{ end }} 24 | 37 | 38 | 39 | 42 | 47 | -------------------------------------------------------------------------------- /static/css/highlightjs/monokai.css: -------------------------------------------------------------------------------- 1 | /* 2 | Monokai style - ported by Luigi Maselli - http://grigio.org 3 | */ 4 | 5 | .hljs { 6 | display: block; 7 | overflow-x: auto; 8 | padding: 0.5em; 9 | background: #272822; 10 | -webkit-text-size-adjust: none; 11 | } 12 | 13 | .hljs-tag, 14 | .hljs-tag .hljs-title, 15 | .hljs-keyword, 16 | .hljs-literal, 17 | .hljs-strong, 18 | .hljs-change, 19 | .hljs-winutils, 20 | .hljs-flow, 21 | .nginx .hljs-title, 22 | .tex .hljs-special { 23 | color: #f92672; 24 | } 25 | 26 | .hljs { 27 | color: #ddd; 28 | } 29 | 30 | .hljs .hljs-constant, 31 | .asciidoc .hljs-code, 32 | .markdown .hljs-code { 33 | color: #66d9ef; 34 | } 35 | 36 | .hljs-code, 37 | .hljs-class .hljs-title, 38 | .hljs-header { 39 | color: white; 40 | } 41 | 42 | .hljs-link_label, 43 | .hljs-attribute, 44 | .hljs-symbol, 45 | .hljs-symbol .hljs-string, 46 | .hljs-value, 47 | .hljs-regexp { 48 | color: #bf79db; 49 | } 50 | 51 | .hljs-link_url, 52 | .hljs-tag .hljs-value, 53 | .hljs-string, 54 | .hljs-bullet, 55 | .hljs-subst, 56 | .hljs-title, 57 | .hljs-emphasis, 58 | .hljs-type, 59 | .hljs-preprocessor, 60 | .hljs-pragma, 61 | .ruby .hljs-class .hljs-parent, 62 | .hljs-built_in, 63 | .django .hljs-template_tag, 64 | .django .hljs-variable, 65 | .smalltalk .hljs-class, 66 | .hljs-javadoc, 67 | .django .hljs-filter .hljs-argument, 68 | .smalltalk .hljs-localvars, 69 | .smalltalk .hljs-array, 70 | .hljs-attr_selector, 71 | .hljs-pseudo, 72 | .hljs-addition, 73 | .hljs-stream, 74 | .hljs-envvar, 75 | .apache .hljs-tag, 76 | .apache .hljs-cbracket, 77 | .tex .hljs-command, 78 | .hljs-prompt, 79 | .hljs-name { 80 | color: #a6e22e; 81 | } 82 | 83 | .hljs-comment, 84 | .hljs-annotation, 85 | .smartquote, 86 | .hljs-blockquote, 87 | .hljs-horizontal_rule, 88 | .hljs-decorator, 89 | .hljs-pi, 90 | .hljs-doctype, 91 | .hljs-deletion, 92 | .hljs-shebang, 93 | .apache .hljs-sqbracket, 94 | .tex .hljs-formula { 95 | color: #75715e; 96 | } 97 | 98 | .hljs-keyword, 99 | .hljs-literal, 100 | .css .hljs-id, 101 | .hljs-phpdoc, 102 | .hljs-dartdoc, 103 | .hljs-title, 104 | .hljs-header, 105 | .hljs-type, 106 | .vbscript .hljs-built_in, 107 | .rsl .hljs-built_in, 108 | .smalltalk .hljs-class, 109 | .diff .hljs-header, 110 | .hljs-chunk, 111 | .hljs-winutils, 112 | .bash .hljs-variable, 113 | .apache .hljs-tag, 114 | .tex .hljs-special, 115 | .hljs-request, 116 | .hljs-status { 117 | font-weight: bold; 118 | } 119 | 120 | .coffeescript .javascript, 121 | .javascript .xml, 122 | .tex .hljs-formula, 123 | .xml .javascript, 124 | .xml .vbscript, 125 | .xml .css, 126 | .xml .hljs-cdata { 127 | opacity: 0.5; 128 | } 129 | -------------------------------------------------------------------------------- /exampleSite/content/post/hugo-is-for-lovers.md: -------------------------------------------------------------------------------- 1 | +++ 2 | date = "2015-08-03T13:39:46+02:00" 3 | tags = ["Hugo"] 4 | title = "Hugo is for lovers" 5 | +++ 6 | 7 | ## Step 1. Install Hugo 8 | 9 | Goto [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 [installing hugo](/overview/installing/) 15 | 16 | 17 | 18 | ## Step 2. Build the Docs 19 | 20 | Hugo has its own example site which happens to also be the documentation site 21 | you are reading right now. 22 | 23 | Follow the following steps: 24 | 25 | 1. Clone the [hugo repository](http://github.com/spf13/hugo) 26 | 2. Go into the repo 27 | 3. Run hugo in server mode and build the docs 28 | 4. Open your browser to http://localhost:1313 29 | 30 | Corresponding pseudo commands: 31 | 32 | git clone https://github.com/spf13/hugo 33 | cd hugo 34 | /path/to/where/you/installed/hugo server --source=./docs 35 | > 29 pages created 36 | > 0 tags index created 37 | > in 27 ms 38 | > Web Server is available at http://localhost:1313 39 | > Press ctrl+c to stop 40 | 41 | Once you've gotten here, follow along the rest of this page on your local build. 42 | 43 | ## Step 3. Change the docs site 44 | 45 | Stop the Hugo process by hitting ctrl+c. 46 | 47 | Now we are going to run hugo again, but this time with hugo in watch mode. 48 | 49 | /path/to/hugo/from/step/1/hugo server --source=./docs --watch 50 | > 29 pages created 51 | > 0 tags index created 52 | > in 27 ms 53 | > Web Server is available at http://localhost:1313 54 | > Watching for changes in /Users/spf13/Code/hugo/docs/content 55 | > Press ctrl+c to stop 56 | 57 | 58 | Open your [favorite editor](http://vim.spf13.com) and change one of the source 59 | content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*. 60 | 61 | Content files are found in `docs/content/`. Unless otherwise specified, files 62 | are located at the same relative location as the url, in our case 63 | `docs/content/overview/quickstart.md`. 64 | 65 | Change and save this file.. Notice what happened in your terminal. 66 | 67 | > Change detected, rebuilding site 68 | 69 | > 29 pages created 70 | > 0 tags index created 71 | > in 26 ms 72 | 73 | Refresh the browser and observe that the typo is now fixed. 74 | 75 | Notice how quick that was. Try to refresh the site before it's finished building.. I double dare you. 76 | Having nearly instant feedback enables you to have your creativity flow without waiting for long builds. 77 | 78 | ## Step 4. Have fun 79 | 80 | The best way to learn something is to play with it. 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Minimalist 3 | 4 | Minimalist is a responsive theme with a focus on blogging based on the 5 | [Minimalistic](https://github.com/rriegger/MinimalisticBlogTheme) 6 | Ghost theme made by [Raphael Riegger](https://github.com/rriegger). 7 | 8 | Noteworthy features of this Hugo theme are the integration of a comment-system 9 | powered by Disqus, easy localization (l10n), support for RSS feeds, 10 | syntax highlighting for source code and sharing options in the blog posts. 11 | 12 | #### Please note that this theme is no longer maintained. 13 | 14 | ![](https://raw.githubusercontent.com/digitalcraftsman/hugo-minimalist-theme/master/images/screenshot.png) 15 | 16 | ## Preview & Installation 17 | 18 | ### Preview 19 | 20 | The theme ships with an `exampleSite` folder that acts as a demo setup. 21 | `cd` into this folder an start the Hugo: 22 | 23 | git clone https://github.com/digitalcraftsman/hugo-minimalist-theme.git 24 | cd hugo-minimalist-theme/exampleSite 25 | hugo server 26 | 27 | Now enter [`localhost:1313`](http://localhost:1313) in the address bar of your browser. 28 | 29 | ### Installation 30 | 31 | If you want to use this theme for an actual website create a new Hugo project and clone the theme: 32 | 33 | cd themes 34 | git clone https://github.com/digitalcraftsman/hugo-minimalist-theme.git 35 | 36 | **Note:** make sure to remove `themesDir = "../.."` from the top of your config file if you copied it from `exampleSite/config.toml`. Otherwise, Hugo will be unable to find the theme. 37 | 38 | For more information read the official [setup guide](//gohugo.io/overview/installing/) of Hugo. 39 | 40 | ### The Config File 41 | 42 | Take a look inside the [`exampleSite`](https://github.com/digitalcraftsman/hugo-minimalist-theme/tree/master/exampleSite) folder of this theme. 43 | You'll find a file called [`config.toml`](https://github.com/digitalcraftsman/hugo-minimalist-theme/blob/master/exampleSite/config.toml). 44 | 45 | To use it, copy the [`config.toml`](https://github.com/digitalcraftsman/hugo-minimalist-theme/blob/master/exampleSite/config.toml) to the root folder of your Hugo site. 46 | Play around with the settings to tweak your site as you like. 47 | 48 | ## Localization (l10n) 49 | 50 | Localization allows you to easily translate all strings in our website. 51 | Within [`exampleSite/data`](https://github.com/digitalcraftsman/hugo-minimalist-theme/tree/master/exampleSite/data) you'll find a file called [`l10n.toml`](https://github.com/digitalcraftsman/hugo-minimalist-theme/blob/master/exampleSite/data/l10n.toml). 52 | If you're not blogging in English replace all strings with their equivalents of your preferred language. 53 | 54 | ## Contributing 55 | 56 | Did you find a bug or have an idea for a new feature? 57 | Feel free to use the [issue tracker](https://github.com/digitalcraftsman/hugo-minimalist-theme/issues) 58 | to let me know. Or create a [pull request](https://github.com/digitalcraftsman/hugo-minimalist-theme/pulls). 59 | **Please create a seperate branch for your pull request.** 60 | 61 | ## License 62 | 63 | This theme is released under the Apache License 2.0. 64 | For more information read the [License](https://github.com/digitalcraftsman/hugo-minimalist-theme/blob/dev/LICENSE.md). 65 | 66 | ## Acknowledgements 67 | 68 | Thanks to 69 | 70 | - [Raphael Riegger](https://github.com/rriegger) for creating the original theme 71 | - [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project 72 | -------------------------------------------------------------------------------- /static/font/fontello.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2014 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /exampleSite/content/post/migrate-from-jekyll.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "Migrate from Jekyll" 3 | date = "2015-10-10T13:07:31+02:00" 4 | tags = ["jekyll", "migration", "hugo"] 5 | +++ 6 | 7 | ## Move static content to `static` 8 | 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. 9 | With Jekyll, something that looked like 10 | 11 | 12 | 13 | ▾ / 14 | ▾ images/ 15 | logo.png 16 | 17 | should become 18 | 19 | ▾ / 20 | ▾ static/ 21 | ▾ images/ 22 | logo.png 23 | 24 | 25 | Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`. 26 | 27 | ## Create your Hugo configuration file 28 | 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. 29 | 30 | ## Set your configuration publish folder to `_site` 31 | 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: 32 | 33 | 1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended). 34 | 35 | git submodule deinit _site 36 | git rm _site 37 | git submodule add -b gh-pages git@github.com:your-username/your-repo.git public 38 | 39 | 2. Or, change the Hugo configuration to use `_site` instead of `public`. 40 | 41 | { 42 | .. 43 | "publishdir": "_site", 44 | .. 45 | } 46 | 47 | ## Convert Jekyll templates to Hugo templates 48 | 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. 49 | 50 | As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours. 51 | 52 | ## Convert Jekyll plugins to Hugo shortcodes 53 | Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port. 54 | 55 | ### Implementation 56 | 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. 57 | 58 | Jekyll's plugin: 59 | 60 | module Jekyll 61 | class ImageTag < Liquid::Tag 62 | @url = nil 63 | @caption = nil 64 | @class = nil 65 | @link = nil 66 | // Patterns 67 | IMAGE_URL_WITH_CLASS_AND_CAPTION = 68 | IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i 69 | IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i 70 | IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i 71 | IMAGE_URL = /((https?:\/\/|\/)(\S+))/i 72 | def initialize(tag_name, markup, tokens) 73 | super 74 | if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK 75 | @class = $1 76 | @url = $3 77 | @caption = $7 78 | @link = $9 79 | elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION 80 | @class = $1 81 | @url = $3 82 | @caption = $7 83 | elsif markup =~ IMAGE_URL_WITH_CAPTION 84 | @url = $1 85 | @caption = $5 86 | elsif markup =~ IMAGE_URL_WITH_CLASS 87 | @class = $1 88 | @url = $3 89 | elsif markup =~ IMAGE_URL 90 | @url = $1 91 | end 92 | end 93 | def render(context) 94 | if @class 95 | source = "
    " 96 | else 97 | source = "
    " 98 | end 99 | if @link 100 | source += "" 101 | end 102 | source += "" 103 | if @link 104 | source += "" 105 | end 106 | source += "
    #{@caption}
    " if @caption 107 | source += "
    " 108 | source 109 | end 110 | end 111 | end 112 | Liquid::Template.register_tag('image', Jekyll::ImageTag) 113 | 114 | is written as this Hugo shortcode: 115 | 116 | 117 |
    118 | {{ with .Get "link"}}{{ end }} 119 | 120 | {{ if .Get "link"}}{{ end }} 121 | {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} 122 |
    {{ if isset .Params "title" }} 123 | {{ .Get "title" }}{{ end }} 124 | {{ if or (.Get "caption") (.Get "attr")}}

    125 | {{ .Get "caption" }} 126 | {{ with .Get "attrlink"}} {{ end }} 127 | {{ .Get "attr" }} 128 | {{ if .Get "attrlink"}} {{ end }} 129 |

    {{ end }} 130 |
    131 | {{ end }} 132 |
    133 | 134 | 135 | ### Usage 136 | I simply changed: 137 | 138 | {% 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/ %} 139 | 140 | to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`): 141 | 142 | {{%/* 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/" */%}} 143 | 144 | As a bonus, the shortcode named parameters are, arguably, more readable. 145 | 146 | ## Finishing touches 147 | ### Fix content 148 | 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. 149 | 150 | ### Clean up 151 | You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it. 152 | 153 | ## A practical example in a diff 154 | [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). 155 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2014 Raphael Riegger, 2015 Digitalcraftsman 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | -------------------------------------------------------------------------------- /exampleSite/content/post/go-is-for-lovers.md: -------------------------------------------------------------------------------- 1 | +++ 2 | date = "2015-09-17T13:47:08+02:00" 3 | tags = [] 4 | title = "Go is for lovers" 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 | Go lang 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 `