├── exampleSite ├── static │ └── .gitkeep ├── content │ ├── about.md │ └── post │ │ ├── math-example.md │ │ ├── hugoisforlovers.md │ │ ├── migrate-from-jekyll.md │ │ ├── goisforlovers.md │ │ └── creating-a-new-theme.md └── config.toml ├── layouts ├── index.html ├── partials │ ├── tags.html │ ├── nav.html │ ├── disqus.html │ ├── pager.html │ ├── footer.html │ ├── sharing.html │ └── header.html ├── 404.html └── _default │ ├── single.html │ └── list.html ├── images ├── tn.png ├── screenshot.png └── screenshot_github.png ├── static ├── wave.ico └── css │ └── style.css ├── archetypes └── default.md ├── package.json ├── theme.toml ├── gulpfile.js ├── LICENSE.md ├── sass └── style.sass └── README.md /exampleSite/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /layouts/index.html: -------------------------------------------------------------------------------- 1 | {{ template "_default/list.html" . }} 2 | -------------------------------------------------------------------------------- /images/tn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojoaar/hucore/master/images/tn.png -------------------------------------------------------------------------------- /static/wave.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojoaar/hucore/master/static/wave.ico -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojoaar/hucore/master/images/screenshot.png -------------------------------------------------------------------------------- /images/screenshot_github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojoaar/hucore/master/images/screenshot_github.png -------------------------------------------------------------------------------- /archetypes/default.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "{{ replace .TranslationBaseName "-" " " | title }}" 3 | tags = [ ] 4 | draft = true 5 | date = {{ .Date }} 6 | author = "" 7 | +++ 8 | -------------------------------------------------------------------------------- /layouts/partials/tags.html: -------------------------------------------------------------------------------- 1 |
2 | {{ range . }} 3 | {{ . }} 4 | {{ end }} 5 |
6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hemingway", 3 | "devDependencies": { 4 | "bulma": "^0.1.2", 5 | "gulp": "^3.9.1", 6 | "gulp-autoprefixer": "^3.1.1", 7 | "gulp-sass": "^2.3.2" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /layouts/404.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 |
3 |
4 |
5 |

404

6 |

7 | Page not found 8 |

9 | Home Page 10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /theme.toml: -------------------------------------------------------------------------------- 1 | # theme.toml template for a Hugo theme 2 | # See https://github.com/spf13/hugoThemes#themetoml for an example 3 | 4 | name = "HUCORE" 5 | license = "MIT" 6 | licenselink = "https://github.com/mgjohansen/hucore/blob/master/LICENSE.md" 7 | description = "Minimal blog theme for hugo based on Hemingway2" 8 | homepage = "https://github.com/mgjohansen/hucore" 9 | tags = ["blog", "font awesome", "highlight.js"] 10 | features = ["html5", "css3", "tags"] 11 | min_version = 0.16 12 | 13 | [author] 14 | name = "Morten G. Johansen" 15 | homepage = "https://github.com/mgjohansen" -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var sass = require('gulp-sass'); 3 | var autoprefixer = require('gulp-autoprefixer'); 4 | 5 | gulp.task("default", function () { 6 | gulp.src('sass/style.sass') 7 | .pipe(sass({outputStyle: 'compressed'})) 8 | .pipe(autoprefixer()) 9 | .pipe(gulp.dest('static/css/')); 10 | }); 11 | 12 | gulp.task("watch", function () { 13 | gulp.watch('sass/style.sass', function() { 14 | gulp.src('sass/style.sass') 15 | .pipe(sass({outputStyle: 'compressed'})) 16 | .pipe(autoprefixer()) 17 | .pipe(gulp.dest('static/css/')); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /layouts/partials/nav.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /layouts/_default/single.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 | 3 | {{ partial "nav" . }} 4 |
5 |
6 |

{{ .Title }}

7 |

{{ .Date.Format "January 2, 2006" }} {{ if (ne ($.Param "displayauthor") false) }}by {{ .Params.author | default .Site.Params.author }}{{ end }}

8 | {{ if .Params.tags }} 9 | {{ partial "tags" .Params.tags }} 10 | {{ end }} 11 |
12 | {{ .Content }} 13 |
14 | {{ if (ne ($.Param "sharingicons") false) }} 15 | {{ partial "sharing.html" . }} 16 | {{ end }} 17 |
18 |
19 | {{ partial "disqus" . }} 20 | {{ partial "footer" . }} 21 | 22 | -------------------------------------------------------------------------------- /layouts/partials/disqus.html: -------------------------------------------------------------------------------- 1 | {{ if .Site.DisqusShortname }} 2 |
3 |
4 | 5 | 13 | 14 |
15 |
16 | {{ end }} 17 | -------------------------------------------------------------------------------- /layouts/_default/list.html: -------------------------------------------------------------------------------- 1 | {{ partial "header" . }} 2 | {{ partial "nav" . }} 3 |
4 |
5 | {{ range sort .Paginator.Pages }} 6 |
7 |

{{ .Title }}{{ if .Draft }} ::Draft{{ end }}

8 |

{{ .Date.Format "January 2, 2006" }}

9 | {{ if .Params.tags }} 10 | {{ partial "tags" .Params.tags }} 11 | {{ end }} 12 |
13 | {{ .Summary | plainify | safeHTML }} 14 | {{ if .Truncated }} 15 | ... 16 | Read more 17 | 18 | 19 | 20 | 21 | {{ end }} 22 |
23 |
24 | {{ end }} 25 |
26 |
27 | {{ partial "pager" . }} 28 | {{ partial "footer" . }} 29 | -------------------------------------------------------------------------------- /layouts/partials/pager.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 29 |
30 |
31 | -------------------------------------------------------------------------------- /layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

{{ .Site.Copyright | safeHTML }}

4 |
5 |
6 | 7 | {{ if .Site.Params.highlight.theme }} 8 | 9 | {{ end }} 10 | 11 | {{ range .Site.Params.highlight.languages }} 12 | 13 | 14 | {{ end }} 15 | 16 | {{ if .Site.GoogleAnalytics }} 17 | {{ template "_internal/google_analytics_async.html" . }} 18 | {{ end }} 19 | -------------------------------------------------------------------------------- /exampleSite/content/about.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "About Hugo" 3 | date = "2014-04-09" 4 | menu = "main" 5 | +++ 6 | 7 | Hugo is a static site engine written in Go. 8 | 9 | 10 | It makes use of a variety of open source projects including: 11 | 12 | * [Cobra](https://github.com/spf13/cobra) 13 | * [Viper](https://github.com/spf13/viper) 14 | * [J Walter Weatherman](https://github.com/spf13/jWalterWeatherman) 15 | * [Cast](https://github.com/spf13/cast) 16 | 17 | Learn more and contribute on [GitHub](https://github.com/spf13). 18 | 19 | ## Setup 20 | 21 | Some fun facts about [Hugo](http://gohugo.io/): 22 | 23 | * Built in [Go](http://golang.org/) 24 | * Loosely inspired by [Jekyll](http://jekyllrb.com/) 25 | * Primarily developed by [spf13](http://spf13.com/) on the train while commuting to and from Manhattan. 26 | * Coded in [Vim](http://vim.org) using [spf13-vim](http://vim.spf13.com/) 27 | 28 | Have questions or suggestions? Feel free to [open an issue on GitHub](https://github.com/spf13/hugo/issues/new) or [ask me on Twitter](https://twitter.com/spf13). 29 | 30 | Thanks for reading! 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Morten G. Johansen 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/sharing.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exampleSite/config.toml: -------------------------------------------------------------------------------- 1 | baseurl = "https://example.com" 2 | languageCode = "en-US" 3 | title = "[Hu]Core" 4 | theme = "Hucore" 5 | copyright = "© 2017 | Follow on Twitter | [Hu]Core theme & Hugo ♥" 6 | disqusShortname = "shortname" 7 | googleAnalytics = "trackingcode" 8 | 9 | [taxonomies] 10 | tag = "tags" 11 | category = "categories" 12 | 13 | [params] 14 | description = "Your description here" 15 | keywords = ["keyword 1", "keyword 2", "keyword 3"] 16 | author = "Morten Johansen" 17 | sharingicons = true 18 | displayauthor = true 19 | 20 | [params.highlight] 21 | style = "github" 22 | languages = ["go", "dockerfile"] 23 | 24 | [[params.social]] 25 | url = "https://github.com/mgjohansen" 26 | fa_icon = "fa-github" 27 | 28 | [[params.social]] 29 | url = "https://gitlab.com/mgjohansen" 30 | fa_icon = "fa-gitlab" 31 | 32 | [[params.social]] 33 | url = "https://twitter.com/mgjohansen" 34 | fa_icon = "fa-twitter" 35 | 36 | [[params.social]] 37 | url = "https://linkedin.com/in/mgjohansen" 38 | fa_icon = "fa-linkedin-square" 39 | 40 | [[params.social]] 41 | url = "/index.xml" 42 | fa_icon = "fa-rss" 43 | 44 | [[params.socialshare]] 45 | url = "https://linkedin.com/in/mgjohansen" 46 | fa_icon = "fa-linkedin-square" -------------------------------------------------------------------------------- /exampleSite/content/post/math-example.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "Math example" 3 | description = "" 4 | tags = [ 5 | "go", 6 | "golang", 7 | "hugo", 8 | "development", 9 | "math equations", 10 | ] 11 | date = "2014-05-11" 12 | categories = [ 13 | "Development", 14 | "golang", 15 | ] 16 | menu = "main" 17 | +++ 18 | MathJax can render latex math equations in webpages. 19 | $$ 20 | \phi = \frac{(1+\sqrt{5})}{2} = 1.6180339887\cdots 21 | $$ 22 | 23 | Additional details can be found on [GitHub](https://github.com/mathjax/) or on the [Documentaion](https://www.mathjax.org/#docs). 24 | 25 | 26 | ### Example 1 27 | 28 | If the text between $$ contains newlines it will rendered in display mode: 29 | ``` 30 | $$ 31 | f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi 32 | $$ 33 | ``` 34 | $$ 35 | f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi 36 | $$ 37 | 38 | 39 | ### Example 2 40 | ``` 41 | $$ 42 | \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } 43 | $$ 44 | ``` 45 | ​​$$ 46 | \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } 47 | $$ 48 | ​​ 49 | 50 | ### Example 3 51 | ``` 52 | $$ 53 | 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. 54 | $$ 55 | ``` 56 | $$ 57 | 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. 58 | $$ -------------------------------------------------------------------------------- /layouts/partials/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{ .Title }}{{ if eq .IsHome false }} | {{ .Site.Title }}{{ end }} 13 | 14 | 22 | 23 | 24 | 25 | {{ with .Site.Params.highlight.style }} 26 | 27 | {{ else }} 28 | 29 | {{ end }} 30 | 31 | -------------------------------------------------------------------------------- /sass/style.sass: -------------------------------------------------------------------------------- 1 | $blue: #2077b2 2 | $primary: $blue 3 | $grey-dark: #42464c 4 | $family-sans-serif: "PingFangSC-Regula", "微软雅黑", "Microsoft YaHei", sans-serif 5 | 6 | @import "node_modules/bulma/bulma" 7 | 8 | .container 9 | max-width: 800px 10 | margin: 0 auto 11 | 12 | .content 13 | font-size: 16px 14 | line-height: 1.75 15 | 16 | .media-content 17 | .subtitle+.title 18 | margin-bottom: 10px 19 | .content 20 | line-height: 1.5 21 | 22 | .hero .nav 23 | box-shadow: none 24 | 25 | html 26 | background-color: transparent 27 | 28 | .section 29 | padding: 40px 20px 30 | 31 | .nav .level-item 32 | margin-left: 10px 33 | 34 | nav .level 35 | padding-top: 14px 36 | padding-bot: 6px 37 | 38 | .subtitle 39 | color: #69707a 40 | 41 | .title 42 | line-height: 1.25 43 | font-size: 24px 44 | a 45 | color: #222324 46 | &.notfound 47 | font-size: 20vw 48 | 49 | code 50 | color: inherit 51 | background-color: transparent 52 | font-size: 90% 53 | 54 | 55 | 56 | article+article 57 | margin-top: 80px 58 | 59 | .content 60 | h1, h2, h3, h4, h5, h6 61 | line-height: 1.25 62 | &:not(:first-child) 63 | margin-top: 80px 64 | &::before 65 | color: #aeb1b5 66 | font-weight: bold 67 | code 68 | background-color: #f8f8f8 69 | h1+h2:not(:first-child), 70 | h2+h3:not(:first-child), 71 | h3+h4:not(:first-child), 72 | h4+h5:not(:first-child), 73 | h5+h6:not(:first-child) 74 | margin-top: 20px 75 | h1 76 | font-size: 24px 77 | &::before 78 | content: "# " 79 | h2 80 | font-size: 22px 81 | &::before 82 | content: "## " 83 | h3 84 | font-size: 20px 85 | &::before 86 | content: "### " 87 | h4 88 | font-size: 18px 89 | &::before 90 | content: "#### " 91 | h5 92 | font-size: 17px 93 | &::before 94 | content: "##### " 95 | h6 96 | font-size: 16px 97 | &::before 98 | content: "###### " 99 | p, 100 | ol, 101 | ul, 102 | pre, 103 | table 104 | &:not(:last-child) 105 | margin-bottom: 1.5em 106 | table 107 | td, 108 | th 109 | border: 1px solid #d3d6db 110 | padding: 8px 10px 111 | vertical-align: top 112 | & > code, p > code 113 | font-size: 90% 114 | padding: 2px 4px 115 | margin: 0 2px 116 | border: 1px solid #ddd 117 | border-radius: 4px 118 | background-color: #f8f8f8 119 | color: #42464c 120 | pre 121 | code 122 | font-size: 90% 123 | padding: 1em 124 | line-height: 1.5 125 | li 126 | pre, 127 | table 128 | margin-bottom: 1.5em 129 | -------------------------------------------------------------------------------- /exampleSite/content/post/hugoisforlovers.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "Getting Started with Hugo" 3 | description = "" 4 | tags = [ 5 | "go", 6 | "golang", 7 | "hugo", 8 | "development", 9 | ] 10 | date = "2014-04-02" 11 | categories = [ 12 | "Development", 13 | "golang", 14 | ] 15 | menu = "main" 16 | +++ 17 | 18 | ## Step 1. Install Hugo 19 | 20 | Goto [hugo releases](https://github.com/spf13/hugo/releases) and download the 21 | appropriate version for your os and architecture. 22 | 23 | Save it somewhere specific as we will be using it in the next step. 24 | 25 | More complete instructions are available at [installing hugo](/overview/installing/) 26 | 27 | ## Step 2. Build the Docs 28 | 29 | Hugo has its own example site which happens to also be the documentation site 30 | you are reading right now. 31 | 32 | Follow the following steps: 33 | 34 | 1. Clone the [hugo repository](http://github.com/spf13/hugo) 35 | 2. Go into the repo 36 | 3. Run hugo in server mode and build the docs 37 | 4. Open your browser to http://localhost:1313 38 | 39 | Corresponding pseudo commands: 40 | 41 | git clone https://github.com/spf13/hugo 42 | cd hugo 43 | /path/to/where/you/installed/hugo server --source=./docs 44 | > 29 pages created 45 | > 0 tags index created 46 | > in 27 ms 47 | > Web Server is available at http://localhost:1313 48 | > Press ctrl+c to stop 49 | 50 | Once you've gotten here, follow along the rest of this page on your local build. 51 | 52 | ## Step 3. Change the docs site 53 | 54 | Stop the Hugo process by hitting ctrl+c. 55 | 56 | Now we are going to run hugo again, but this time with hugo in watch mode. 57 | 58 | /path/to/hugo/from/step/1/hugo server --source=./docs --watch 59 | > 29 pages created 60 | > 0 tags index created 61 | > in 27 ms 62 | > Web Server is available at http://localhost:1313 63 | > Watching for changes in /Users/spf13/Code/hugo/docs/content 64 | > Press ctrl+c to stop 65 | 66 | 67 | Open your [favorite editor](http://vim.spf13.com) and change one of the source 68 | content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*. 69 | 70 | Content files are found in `docs/content/`. Unless otherwise specified, files 71 | are located at the same relative location as the url, in our case 72 | `docs/content/overview/quickstart.md`. 73 | 74 | Change and save this file.. Notice what happened in your terminal. 75 | 76 | > Change detected, rebuilding site 77 | 78 | > 29 pages created 79 | > 0 tags index created 80 | > in 26 ms 81 | 82 | Refresh the browser and observe that the typo is now fixed. 83 | 84 | Notice how quick that was. Try to refresh the site before it's finished building.. I double dare you. 85 | Having nearly instant feedback enables you to have your creativity flow without waiting for long builds. 86 | 87 | ## Step 4. Have fun 88 | 89 | The best way to learn something is to play with it. 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hucore 2 | 3 | Hucore is a minimal blog theme for [hugo](https://gohugo.io). The theme is based on [Hemingway2](https://gitlab.com/beli3ver/hemingway2). 4 | 5 | ## Features 6 | 7 | * Responsive & minimal design 8 | * Disqus support 9 | * Google Analytics 10 | * Basic [OpenGraph](http://ogp.me/) metadata support 11 | * Option for social sharing icons on posts 12 | * Option for author on posts 13 | 14 | ## Screenshot 15 | 16 | ![](https://raw.githubusercontent.com/mgjohansen/hucore/master/images/screenshot_github.png) 17 | 18 | See [technet.cc](https://technet.cc) for an example of this theme in use. 19 | 20 | ## Getting Started 21 | 22 | Clone this repository to your hugo theme directory. 23 | 24 | ``` 25 | mkdir themes 26 | cd themes 27 | git clone https://github.com/mgjohansen/hucore.git 28 | ``` 29 | 30 | ## Configuration 31 | 32 | Take a look in the [exampleSite](https://github.com/mgjohansen/hucore/tree/master/exampleSite) folder. 33 | 34 | This directory contains an example config file and the content for the demo. 35 | It serves as an example setup for your documentation. 36 | 37 | Copy the `config.toml` in the root directory of your website. Overwrite the existing config file if necessary. 38 | 39 | __[config.toml](https://github.com/mgjohansen/hucore/blob/master/exampleSite/config.toml)__: 40 | 41 | ```toml 42 | baseurl = "https://example.com" 43 | languageCode = "en-US" 44 | title = "[Hu]Core" 45 | theme = "Hucore" 46 | copyright = "© 2017 | Follow on Twitter | [Hu]Core theme & Hugo ♥" 47 | disqusShortname = "shortname" 48 | googleAnalytics = "trackingcode" 49 | 50 | [taxonomies] 51 | tag = "tags" 52 | category = "categories" 53 | 54 | [params] 55 | description = "Your description here" 56 | keywords = ["keyword 1", "keyword 2", "keyword 3"] 57 | author = "Morten Johansen" 58 | sharingicons = true 59 | displayauthor = true 60 | 61 | [params.highlight] 62 | style = "github" 63 | languages = ["go", "dockerfile"] 64 | 65 | [[params.social]] 66 | url = "https://github.com/mgjohansen" 67 | fa_icon = "fa-github" 68 | 69 | [[params.social]] 70 | url = "https://gitlab.com/mgjohansen" 71 | fa_icon = "fa-gitlab" 72 | 73 | [[params.social]] 74 | url = "https://twitter.com/mgjohansen" 75 | fa_icon = "fa-twitter" 76 | 77 | [[params.social]] 78 | url = "https://linkedin.com/in/mgjohansen" 79 | fa_icon = "fa-linkedin-square" 80 | 81 | [[params.social]] 82 | url = "/index.xml" 83 | fa_icon = "fa-rss" 84 | 85 | [[params.socialshare]] 86 | url = "https://linkedin.com/in/mgjohansen" 87 | fa_icon = "fa-linkedin-square" 88 | ``` 89 | 90 | ## Build 91 | 92 | ``` 93 | hugo server 94 | ``` 95 | 96 | You can go to localhost:1313 and this theme should be visible. 97 | 98 | ## License 99 | 100 | Hucore is licensed under the [MIT License](LICENSE.md). 101 | 102 | ## Author 103 | 104 | [Morten Johansen](https://github.com/mgjohansen) 105 | 106 | ## Credits 107 | 108 | Hucore is based on [Hemingway2](https://gitlab.com/beli3ver/hemingway2) created by [Malte Kiefer](https://github.com/beli3ver). 109 | -------------------------------------------------------------------------------- /exampleSite/content/post/migrate-from-jekyll.md: -------------------------------------------------------------------------------- 1 | --- 2 | date: 2014-03-10 3 | linktitle: Migrating from Jekyll 4 | menu: 5 | main: 6 | parent: tutorials 7 | prev: /tutorials/mathjax 8 | title: Migrate to Hugo from Jekyll 9 | weight: 10 10 | --- 11 | 12 | ## Move static content to `static` 13 | 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. 14 | With Jekyll, something that looked like 15 | 16 | ▾ / 17 | ▾ images/ 18 | logo.png 19 | 20 | should become 21 | 22 | ▾ / 23 | ▾ static/ 24 | ▾ images/ 25 | logo.png 26 | 27 | Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`. 28 | 29 | ## Create your Hugo configuration file 30 | 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. 31 | 32 | ## Set your configuration publish folder to `_site` 33 | 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: 34 | 35 | 1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended). 36 | 37 | git submodule deinit _site 38 | git rm _site 39 | git submodule add -b gh-pages git@github.com:your-username/your-repo.git public 40 | 41 | 2. Or, change the Hugo configuration to use `_site` instead of `public`. 42 | 43 | { 44 | .. 45 | "publishdir": "_site", 46 | .. 47 | } 48 | 49 | ## Convert Jekyll templates to Hugo templates 50 | 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. 51 | 52 | As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours. 53 | 54 | ## Convert Jekyll plugins to Hugo shortcodes 55 | Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port. 56 | 57 | ### Implementation 58 | 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. 59 | 60 | Jekyll's plugin: 61 | 62 | module Jekyll 63 | class ImageTag < Liquid::Tag 64 | @url = nil 65 | @caption = nil 66 | @class = nil 67 | @link = nil 68 | // Patterns 69 | IMAGE_URL_WITH_CLASS_AND_CAPTION = 70 | IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i 71 | IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i 72 | IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i 73 | IMAGE_URL = /((https?:\/\/|\/)(\S+))/i 74 | def initialize(tag_name, markup, tokens) 75 | super 76 | if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK 77 | @class = $1 78 | @url = $3 79 | @caption = $7 80 | @link = $9 81 | elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION 82 | @class = $1 83 | @url = $3 84 | @caption = $7 85 | elsif markup =~ IMAGE_URL_WITH_CAPTION 86 | @url = $1 87 | @caption = $5 88 | elsif markup =~ IMAGE_URL_WITH_CLASS 89 | @class = $1 90 | @url = $3 91 | elsif markup =~ IMAGE_URL 92 | @url = $1 93 | end 94 | end 95 | def render(context) 96 | if @class 97 | source = "
" 98 | else 99 | source = "
" 100 | end 101 | if @link 102 | source += "" 103 | end 104 | source += "" 105 | if @link 106 | source += "" 107 | end 108 | source += "
#{@caption}
" if @caption 109 | source += "
" 110 | source 111 | end 112 | end 113 | end 114 | Liquid::Template.register_tag('image', Jekyll::ImageTag) 115 | 116 | is written as this Hugo shortcode: 117 | 118 | 119 |
120 | {{ with .Get "link"}}{{ end }} 121 | 122 | {{ if .Get "link"}}{{ end }} 123 | {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} 124 |
{{ if isset .Params "title" }} 125 | {{ .Get "title" }}{{ end }} 126 | {{ if or (.Get "caption") (.Get "attr")}}

127 | {{ .Get "caption" }} 128 | {{ with .Get "attrlink"}} {{ end }} 129 | {{ .Get "attr" }} 130 | {{ if .Get "attrlink"}} {{ end }} 131 |

{{ end }} 132 |
133 | {{ end }} 134 |
135 | 136 | 137 | ### Usage 138 | I simply changed: 139 | 140 | {% 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/ %} 141 | 142 | to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`): 143 | 144 | {{%/* 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/" */%}} 145 | 146 | As a bonus, the shortcode named parameters are, arguably, more readable. 147 | 148 | ## Finishing touches 149 | ### Fix content 150 | 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. 151 | 152 | ### Clean up 153 | You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it. 154 | 155 | ## A practical example in a diff 156 | [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). 157 | -------------------------------------------------------------------------------- /exampleSite/content/post/goisforlovers.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = "(Hu)go Template Primer" 3 | description = "" 4 | tags = [ 5 | "go", 6 | "golang", 7 | "templates", 8 | "themes", 9 | "development", 10 | ] 11 | date = "2014-04-02" 12 | categories = [ 13 | "Development", 14 | "golang", 15 | ] 16 | menu = "main" 17 | +++ 18 | 19 | Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for 20 | its template engine. It is an extremely lightweight engine that provides a very 21 | small amount of logic. In our experience that it is just the right amount of 22 | logic to be able to create a good static website. If you have used other 23 | template systems from different languages or frameworks you will find a lot of 24 | similarities in go templates. 25 | 26 | This document is a brief primer on using go templates. The [go docs][gohtmltemplate] 27 | provide more details. 28 | 29 | ## Introduction to Go Templates 30 | 31 | Go templates provide an extremely simple template language. It adheres to the 32 | belief that only the most basic of logic belongs in the template or view layer. 33 | One consequence of this simplicity is that go templates parse very quickly. 34 | 35 | A unique characteristic of go templates is they are content aware. Variables and 36 | content will be sanitized depending on the context of where they are used. More 37 | details can be found in the [go docs][gohtmltemplate]. 38 | 39 | ## Basic Syntax 40 | 41 | Go lang templates are html files with the addition of variables and 42 | functions. 43 | 44 | **Go variables and functions are accessible within {{ }}** 45 | 46 | Accessing a predefined variable "foo": 47 | 48 | {{ foo }} 49 | 50 | **Parameters are separated using spaces** 51 | 52 | Calling the add function with input of 1, 2: 53 | 54 | {{ add 1 2 }} 55 | 56 | **Methods and fields are accessed via dot notation** 57 | 58 | Accessing the Page Parameter "bar" 59 | 60 | {{ .Params.bar }} 61 | 62 | **Parentheses can be used to group items together** 63 | 64 | {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }} 65 | 66 | 67 | ## Variables 68 | 69 | Each go template has a struct (object) made available to it. In hugo each 70 | template is passed either a page or a node struct depending on which type of 71 | page you are rendering. More details are available on the 72 | [variables](/layout/variables) page. 73 | 74 | A variable is accessed by referencing the variable name. 75 | 76 | {{ .Title }} 77 | 78 | Variables can also be defined and referenced. 79 | 80 | {{ $address := "123 Main St."}} 81 | {{ $address }} 82 | 83 | 84 | ## Functions 85 | 86 | Go template ship with a few functions which provide basic functionality. The go 87 | template system also provides a mechanism for applications to extend the 88 | available functions with their own. [Hugo template 89 | functions](/layout/functions) provide some additional functionality we believe 90 | are useful for building websites. Functions are called by using their name 91 | followed by the required parameters separated by spaces. Template 92 | functions cannot be added without recompiling hugo. 93 | 94 | **Example:** 95 | 96 | {{ add 1 2 }} 97 | 98 | ## Includes 99 | 100 | When including another template you will pass to it the data it will be 101 | able to access. To pass along the current context please remember to 102 | include a trailing dot. The templates location will always be starting at 103 | the /layout/ directory within Hugo. 104 | 105 | **Example:** 106 | 107 | {{ template "chrome/header.html" . }} 108 | 109 | 110 | ## Logic 111 | 112 | Go templates provide the most basic iteration and conditional logic. 113 | 114 | ### Iteration 115 | 116 | Just like in go, the go templates make heavy use of range to iterate over 117 | a map, array or slice. The following are different examples of how to use 118 | range. 119 | 120 | **Example 1: Using Context** 121 | 122 | {{ range array }} 123 | {{ . }} 124 | {{ end }} 125 | 126 | **Example 2: Declaring value variable name** 127 | 128 | {{range $element := array}} 129 | {{ $element }} 130 | {{ end }} 131 | 132 | **Example 2: Declaring key and value variable name** 133 | 134 | {{range $index, $element := array}} 135 | {{ $index }} 136 | {{ $element }} 137 | {{ end }} 138 | 139 | ### Conditionals 140 | 141 | If, else, with, or, & and provide the framework for handling conditional 142 | logic in Go Templates. Like range, each statement is closed with `end`. 143 | 144 | 145 | Go Templates treat the following values as false: 146 | 147 | * false 148 | * 0 149 | * any array, slice, map, or string of length zero 150 | 151 | **Example 1: If** 152 | 153 | {{ if isset .Params "title" }}

{{ index .Params "title" }}

{{ end }} 154 | 155 | **Example 2: If -> Else** 156 | 157 | {{ if isset .Params "alt" }} 158 | {{ index .Params "alt" }} 159 | {{else}} 160 | {{ index .Params "caption" }} 161 | {{ end }} 162 | 163 | **Example 3: And & Or** 164 | 165 | {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} 166 | 167 | **Example 4: With** 168 | 169 | An alternative way of writing "if" and then referencing the same value 170 | is to use "with" instead. With rebinds the context `.` within its scope, 171 | and skips the block if the variable is absent. 172 | 173 | The first example above could be simplified as: 174 | 175 | {{ with .Params.title }}

{{ . }}

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