├── layouts ├── 404.html ├── _default │ ├── _markup │ │ └── render-link.html │ ├── li.html │ ├── list.html │ └── single.html ├── partials │ ├── author_name.html │ ├── runnable-modal.html │ ├── author_image.html │ ├── author_profile.html │ ├── editor_profile.html │ ├── page_header.html │ ├── github_engage_widget.html │ ├── author_detail.html │ ├── header.html │ └── footer.html └── shortcodes │ └── runnable.html ├── exampleSite ├── layouts │ └── .gitkeep ├── static │ ├── .gitignore │ └── images │ │ ├── default.jpg │ │ └── logo.svg ├── .gitignore ├── README.md ├── content │ ├── about.md │ └── post │ │ ├── hugoisforlovers.md │ │ ├── migrate-from-jekyll.md │ │ └── goisforlovers.md ├── LICENSE └── config.toml ├── images ├── tn.png ├── screenshot.png └── dgraph-black.png ├── static ├── images │ └── dgraph-black.png ├── js │ ├── script.min.js │ ├── search.js │ ├── custom.js │ ├── runnable.js │ └── clipboard.min.js └── css │ ├── runnable-custom.css │ ├── github-engage.css │ ├── runnable.css │ ├── heart.scss │ └── heart.css ├── theme.toml ├── LICENSE.md └── README.md /layouts/404.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exampleSite/layouts/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exampleSite/static/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/tn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/HEAD/images/tn.png -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/HEAD/images/screenshot.png -------------------------------------------------------------------------------- /images/dgraph-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/HEAD/images/dgraph-black.png -------------------------------------------------------------------------------- /static/images/dgraph-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/HEAD/static/images/dgraph-black.png -------------------------------------------------------------------------------- /exampleSite/static/images/default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/HEAD/exampleSite/static/images/default.jpg -------------------------------------------------------------------------------- /static/js/script.min.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | var d = $(".browsehappy"); 3 | $(".browsehappy__dismiss").click(d.remove.bind(d)); 4 | }); 5 | -------------------------------------------------------------------------------- /layouts/_default/_markup/render-link.html: -------------------------------------------------------------------------------- 1 | {{ .Text }} -------------------------------------------------------------------------------- /layouts/partials/author_name.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | {{if eq .user "bturner" }} Brandon Turner 9 | {{else if eq .user "molly"}} Molly Graham 10 | {{end}} 11 | -------------------------------------------------------------------------------- /exampleSite/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | 25 | /public 26 | /themes 27 | .DS_Store 28 | -------------------------------------------------------------------------------- /layouts/partials/runnable-modal.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/css/runnable-custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * runnable-custom.css 3 | * 4 | * This file contains CSS rules that overrides the CSS rules specific to blog 5 | * that interferes with runnable styles. 6 | * All CSS rules in this file should be scoped to .runnable or #runnable-modal 7 | * in order to avoid polluting the global CSS namespace for the blog 8 | */ 9 | 10 | .article-content .runnable a { 11 | border-bottom: none; 12 | } 13 | -------------------------------------------------------------------------------- /theme.toml: -------------------------------------------------------------------------------- 1 | name = "Dgraph" 2 | license = "MIT" 3 | licenselink = "https://github.com/dgraph-io/hugo-dgraph-theme/blob/master/LICENSE.md" 4 | description = "An elegant open source theme for your open source project blog." 5 | homepage = "https://blog.dgraph.io/" 6 | tags = ["blog", "company"] 7 | features = ["blog", "github", "discourse","twitter"] 8 | min_version = 0.15 9 | 10 | [author] 11 | name = "Dgraph Labs" 12 | homepage = "https://blog.dgraph.io" 13 | 14 | -------------------------------------------------------------------------------- /layouts/partials/author_image.html: -------------------------------------------------------------------------------- 1 | 8 | 9 | {{if eq .user "bturner" }} 10 | 11 | {{else if eq .user "molly"}} 12 | 13 | {{end}} 14 | -------------------------------------------------------------------------------- /layouts/partials/author_profile.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{partial "author_image.html" (dict "user" .Params.author)}} 4 |
5 |
6 | 9 | {{partial "author_detail.html" (dict "user" .Params.author)}} 10 |
11 |
12 | -------------------------------------------------------------------------------- /layouts/partials/editor_profile.html: -------------------------------------------------------------------------------- 1 | {{if .Params.editor }} 2 |
3 |
4 | {{partial "author_image.html" (dict "user" .Params.editor)}} 5 |
6 |
7 | 10 | {{partial "author_detail.html" (dict "user" .Params.editor)}} 11 |
12 |
13 | {{end}} -------------------------------------------------------------------------------- /exampleSite/README.md: -------------------------------------------------------------------------------- 1 | hugoBasicExample 2 | ========== 3 | 4 | This is an example site for [Hugo](http://gohugo.io/). 5 | 6 | It is intended to be a demo site for the various [Hugo themes][]. 7 | 8 | # Using 9 | 10 | 1. First, [install Hugo](http://gohugo.io/overview/installing/); 11 | 2. Then, clone this repository; 12 | 3. Clone the [Hugo themes][]; 13 | 4. Run Hugo and select the theme of your choosing. 14 | 15 | In other words: 16 | 17 |
git clone https://github.com/spf13/HugoBasicExample.git
18 | cd HugoBasicExample
19 | git clone --recursive https://github.com/spf13/hugoThemes.git themes
20 | hugo server -t themename
21 | 
22 | 23 | Enjoy! 24 | 25 | [Hugo themes]: https://github.com/spf13/hugoThemes 26 | -------------------------------------------------------------------------------- /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 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Dgraph Labs, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /exampleSite/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Steve Francia 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. -------------------------------------------------------------------------------- /layouts/partials/page_header.html: -------------------------------------------------------------------------------- 1 | 37 | 38 | -------------------------------------------------------------------------------- /layouts/_default/li.html: -------------------------------------------------------------------------------- 1 |
  • 2 |
    3 | 6 |
    7 | 8 |

    {{ .Title }}

    9 |
    10 |
    11 | 19 |
    20 |
    {{ .Summary }}
    21 |
    22 | {{ range .Param "tags" }} 23 | {{ $name := . }} 24 | {{ with $.Site.GetPage (printf "/%s/%s" "tags" ($name | urlize)) }} 25 | {{ $name }} 26 | {{ end }} 27 | {{ end }} 28 |
    29 |
    30 |
    31 |
  • 32 | -------------------------------------------------------------------------------- /exampleSite/config.toml: -------------------------------------------------------------------------------- 1 | 2 | baseurl = "http://hugo.spf13.com/" 3 | title = "Hugo Themes" 4 | author = "Steve Francia" 5 | theme = "hugo-dgraph-theme" 6 | themesDir = "../.." 7 | 8 | # Number of blogs you want to list on a single page. 9 | paginate = 5 10 | paginatePath ="page" 11 | 12 | [params] 13 | googleAnalytics = "" 14 | 15 | # To integrate discourse commenting system and also to display discourse in the footer. 16 | discourse = "https://discuss.dgraph.io" 17 | 18 | # The path of the repo excluding https://github.com. This would work only for public repos. It is used for displaying stars for the repo. 19 | github = "dgraph-io/dgraph" 20 | 21 | # Website url, used to have a link in the footer as well as on the top. 22 | website = "https://dgraph.io" 23 | 24 | # Twitter handle for sharing the post via 25 | twitter = "dgraphlabs" 26 | 27 | # Website demo url, used on the top. 28 | demo = "https://dgraph.io" 29 | 30 | # Wiki url, used to have a link in the footer. 31 | wiki = "https://wiki.dgraph.io/" 32 | 33 | # Slack url, used to have a link in the footer. 34 | slack = "https://slack.dgraph.io/" 35 | 36 | # Angel list startup profile name, used to have a link in the footer. 37 | angellist = "dgraph-labs" 38 | 39 | copyright = "Copyright (c) 2008 - 2014, Steve Francia; all rights reserved." 40 | 41 | 42 | -------------------------------------------------------------------------------- /layouts/partials/github_engage_widget.html: -------------------------------------------------------------------------------- 1 |
    2 |
    Do you like our blog?
    3 | 4 | 5 | 6 | 7 |
    8 | 15 | Star us on GitHub 16 | 17 |
    18 |
    19 |
    20 |
    21 |
    22 |
    23 |
    24 |
    25 |
    26 |
    27 |
    28 |
    29 | 30 |
    31 | We Love You! 32 |
    33 |
    34 |
    35 | 36 | 37 | 41 | 45 | 49 | 50 | 55 | 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dgraph 2 | 3 | Dgraph blog theme is an ideal responsive theme for your blog. It has a list view with a image for each post and a beautiful page for individual posts. You can see it live in action on the [Dgraph Blog](https://blog.dgraph.io). 4 | 5 | ![Dgraph screenshot](https://raw.githubusercontent.com/dgraph-io/hugo-dgraph-theme/master/images/screenshot.png) 6 | 7 | ## Features 8 | 9 | * Responsive 10 | * Suited for personal or company blog 11 | * Support for [discourse](https://www.discourse.org) for commenting 12 | * Syntax highlighting for code samples 13 | 14 | ## Installation 15 | 16 | Inside the folder of your Hugo site run: 17 | 18 | ``` 19 | $ cd themes 20 | $ git clone https://github.com/dgraph-io/hugo-dgraph-theme 21 | ``` 22 | 23 | For more information read the official [setup guide](//gohugo.io/overview/installing/) of Hugo. 24 | 25 | ## Site variables 26 | 27 | Please see the sample [`config.toml`](https://github.com/dgraph-io/hugo-dgraph-theme/blob/master/exampleSite/config.toml) under the `exampleSite` directory. 28 | 29 | ## Show Author And Editor Details in Blogs 30 | 31 | Sample files `author_image.html`,`author_name.html` and ``author_detail.html`` for author's and editor's name, image and details are added in `layout/partials/`. 32 | 33 | ## Pagination 34 | 35 | Theme also provides pagination, for changing the number of blogs listed add `paginate = ` to `config.toml` (by default it displays 10 blogs). 36 | 37 | ## Contributing 38 | 39 | Pull requests, bug fixes and new features are welcome! 40 | 41 | We follow [Git flow](http://nvie.com/posts/a-successful-git-branching-model/). So please create feature branches from develop and submit a PR for any change. 42 | 43 | ## License 44 | 45 | Licensed under the MIT License. See the [LICENSE](https://github.com/dgraph-io/hugo-dgraph-theme/blob/master/LICENSE.md) file for more details. 46 | 47 | 48 | ## Credits 49 | 50 | * [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project. 51 | * [Danijel Grabez](https://twitter.com/danijel_grabez) for designing and coding up the theme. 52 | -------------------------------------------------------------------------------- /layouts/_default/list.html: -------------------------------------------------------------------------------- 1 | {{ partial "header.html" . }} 2 | 3 | {{ partial "page_header.html" .}} 4 |
    5 |
    6 | {{ if eq .Page.Kind "taxonomy" }} 7 | 16 | {{ end }} 17 | 18 |
      19 | {{ range .Paginator.Pages }} 20 | {{ .Render "li" }} 21 | {{ end }} 22 |
    23 |
    24 |
    25 | 26 |
    27 |
    28 |
    29 | {{ if .Paginator.HasPrev }} 30 | 31 | <Prev Page 32 | 33 | {{ else }} 34 | 35 | <Prev Page 36 | 37 | {{ end }} 38 | 39 | {{ range $i, $sequence := (seq .Paginator.TotalPages) }} 40 | {{if eq $.Paginator.PageNumber $sequence }} 41 | {{ $sequence }} 42 | {{else}} 43 | {{ $sequence }} 44 | {{end}} 45 | {{ end }} 46 | 47 | {{ if .Paginator.HasNext }} 48 | 51 | {{ else }} 52 | 55 | {{ end }} 56 |
    57 |
    58 |
    59 | 60 | {{ partial "footer.html" . }} 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /static/css/github-engage.css: -------------------------------------------------------------------------------- 1 | .github-engage { 2 | position: fixed; 3 | bottom: -200px; 4 | 5 | height: 100px; 6 | left: 50%; 7 | width: 320px; 8 | margin-left: -160px; 9 | 10 | padding: 10px 22px; 11 | font-size: 18px; 12 | background: #fff; 13 | color: #333; 14 | box-shadow: 0px 1px 20px 2px #888888; 15 | border-radius: 2px; 16 | 17 | text-align: center; 18 | transition: bottom 1.5s ease-in-out; 19 | } 20 | .github-engage.open { 21 | bottom: 4px; 22 | } 23 | 24 | .github-engage.dismissAnimation { 25 | animation: dismissAnimation 0.5s; 26 | transform-origin: 50% 50%; 27 | } 28 | 29 | @keyframes dismissAnimation { 30 | 0% { 31 | bottom: 4px; 32 | transform: scale(1) translateZ(0); 33 | } 34 | 99% { 35 | bottom: -50px; 36 | opacity: 0.1; 37 | transform: scale(0.2); 38 | } 39 | 100% { 40 | bottom: -200px; 41 | } 42 | } 43 | 44 | .github-engage .line1 { 45 | margin-bottom: 16px; 46 | } 47 | .github-engage .github-close { 48 | display: block; 49 | position: absolute; 50 | width: 22px; 51 | height: 22px; 52 | right: -11px; 53 | top: -11px; 54 | background: #ccc; 55 | border-radius: 50%; 56 | overflow:hidden; 57 | color: #fff; 58 | box-shadow: 0px 1px 6px 0 #888888; 59 | 60 | line-height: 21px; 61 | font-size: 14px; 62 | } 63 | .github-engage.love .github-close { 64 | opacity: 0.75; 65 | } 66 | 67 | .github-engage.love .love { 68 | opacity: 0; 69 | position: absolute; 70 | z-index: 1; 71 | top: 0; 72 | bottom: 0; 73 | left: 0; 74 | right: 0; 75 | background-color: #fff; 76 | transition: opacity 500ms ease-in; 77 | } 78 | .github-engage.love { 79 | bottom: -200px; 80 | opacity: 0.5; 81 | z-index: 100; 82 | transition: all 4s cubic-bezier(1,-0.1,1,.25); 83 | } 84 | 85 | .github-engage #star-us-wrapper { 86 | z-index: 100; 87 | position: relative; 88 | display: inline-block; 89 | vertical-align: middle; 90 | } 91 | .github-engage #star-us-wrapper > span { 92 | margin-bottom: -4px; 93 | } 94 | .github-engage.love #star-us-wrapper { 95 | transition: opacity 300ms; 96 | opacity: 0; 97 | z-index: 1; 98 | } 99 | 100 | .github-engage.love .love { 101 | opacity: 1; 102 | } 103 | 104 | .github-engage.love .love .heart-wrapper { 105 | position: absolute; 106 | font-size: 2.5px; 107 | top: 50%; 108 | left: 50%; 109 | transform: translate(-50%, -50%); 110 | } 111 | 112 | .github-engage .love-text { 113 | font-family: 'Indie Flower', cursive; 114 | font-size: 32px; 115 | text-shadow: 0 0 5px #fff; 116 | 117 | position: absolute; 118 | top: 50%; 119 | left: 50%; 120 | transform: translate(-50%, -50%); 121 | 122 | transition: opacity 1s ease-in; 123 | opacity: 0; 124 | } 125 | 126 | .github-engage.love .love-text { 127 | opacity: 1; 128 | } 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 | -------------------------------------------------------------------------------- /layouts/partials/author_detail.html: -------------------------------------------------------------------------------- 1 | 26 | 27 | {{if eq .user "bturner" }} 28 | 46 |

    I’m coffee drinking Boston based Backend Developer with — one project at a time.

    47 | 48 | {{ else if eq .user "molly" }} 49 | 67 |

    I'm Molly Graham, a web developer working in NYC. Plain and simple, I love programming. I'm passionate about writing clean, unique, elegant code. Codes that work.

    68 | {{end}} 69 | -------------------------------------------------------------------------------- /static/js/search.js: -------------------------------------------------------------------------------- 1 | // Algolia vars 2 | const appId = 'H10LQ4I695'; 3 | const publicKey = 'b57c0b5231fd34f2077cf00e76cc8f8e'; 4 | const index = 'dgraph_blog'; 5 | 6 | let showSearch = true; 7 | let widgetContainer = {}; 8 | 9 | // Toggles search interface's visibility 10 | const toggleVisibility = () => { 11 | widgetContainer.style.display = showSearch? "none" : ""; 12 | widgetContainer.querySelector('input').focus(); 13 | showSearch = !showSearch; 14 | } 15 | 16 | const parseSummary = (summary) => summary.trim().replace("

    ", "").replace("

    ", ""); 17 | 18 | // Renders tags 19 | const renderTags = tags => ` 20 |
    21 | ${ 22 | tags.map(tag => ` 23 | 27 | ${tag} 28 | 29 | `) 30 | .join('') 31 | } 32 |
    33 | `; 34 | 35 | // Helper for the render function 36 | const renderIndexListItem = ({ indexId, hits }) => ` 37 |
  • 38 |
    39 |
    40 | ${hits.length} results found. 41 |
    42 |
    43 | 44 |
      45 | ${hits 46 | .slice(0, 5) 47 | .map( 48 | hit => 49 | `
    1. 53 |
      54 | ${instantsearch.highlight({ attribute: 'title', hit })} 55 |
      56 |
      57 | ${parseSummary(hit.summary)} 58 |
      59 |
      60 | ${renderTags(hit.tags || [])} 61 |
      62 |
    2. ` 63 | ) 64 | .join('')} 65 |
    66 |
  • 67 | `; 68 | 69 | // Create the render function 70 | const renderAutocomplete = (renderOptions, isFirstRender) => { 71 | const { indices, currentRefinement, refine, widgetParams } = renderOptions; 72 | 73 | if (isFirstRender) { 74 | const background = document.createElement('div'); 75 | const input = document.createElement('input'); 76 | const ul = document.createElement('ul'); 77 | 78 | background.className = "search-background"; 79 | ul.className = "search-results"; 80 | input.className = "search-input"; 81 | 82 | input.placeholder = "Search..."; 83 | 84 | background.onclick = toggleVisibility; 85 | 86 | input.addEventListener('input', event => { 87 | refine(event.currentTarget.value); 88 | }); 89 | 90 | widgetContainer = widgetParams.container; 91 | 92 | widgetContainer.appendChild(background); 93 | widgetContainer.appendChild(input); 94 | widgetContainer.appendChild(ul); 95 | 96 | toggleVisibility(); 97 | } 98 | 99 | widgetContainer.querySelector('input').value = currentRefinement; 100 | 101 | if (currentRefinement) { 102 | widgetContainer.querySelector('ul').style.display = ""; 103 | widgetContainer.querySelector('ul').innerHTML = indices 104 | .map(renderIndexListItem) 105 | .join(''); 106 | } else { 107 | widgetContainer.querySelector('ul').innerHTML = ""; 108 | widgetContainer.querySelector('ul').style.display = "none" 109 | } 110 | }; 111 | 112 | const createSearch = () => { 113 | // Create the custom widget 114 | const customAutocomplete = instantsearch.connectors.connectAutocomplete( 115 | renderAutocomplete 116 | ); 117 | 118 | // Algolia client 119 | const client = algoliasearch(appId, publicKey); 120 | 121 | const search = instantsearch({ 122 | indexName: index, 123 | searchClient: client, 124 | }); 125 | search.addWidgets([ 126 | customAutocomplete({ 127 | container: document.querySelector('#searchbox'), 128 | }) 129 | ]); 130 | 131 | search.start(); 132 | }; -------------------------------------------------------------------------------- /static/js/custom.js: -------------------------------------------------------------------------------- 1 | // Kitchen Sink of interactive features on the page. 2 | 3 | $(document).ready(function() { 4 | var height = $("#page-header").height() 5 | $("a.internal").click(function(e) { 6 | e.preventDefault(); 7 | var href = $(this).attr("href"); 8 | $('html, body').animate({ 9 | scrollTop: $(href).offset().top - height 10 | }, 0); 11 | }); 12 | }); 13 | 14 | // Fix scroll position after every click on an anchor element. 15 | // Doesn't work when currently targeted anchor is clicked, but good enough 16 | // since this implementation is less likely to break 17 | window.addEventListener("hashchange", function(e) { 18 | var url = e.newURL || "" 19 | var idx = url.lastIndexOf('#') 20 | if (idx > 0) { 21 | var el = document.getElementById(url.substring(idx + 1)) 22 | if (el) { 23 | var offsetTop = 0 24 | while (el) { 25 | offsetTop += el.offsetTop 26 | el = el.offsetParent 27 | } 28 | document.scrollingElement.scrollTop = offsetTop - 100 29 | } 30 | } 31 | }, false); 32 | 33 | (function() { 34 | // This code sets visibility: hidden for images outside the user's viewport. 35 | // It adds a listener for scroll events to perform realtime update of the images state. 36 | var allImages = $('.article-content img') 37 | if (allImages.length < 10) { 38 | return; 39 | } 40 | 41 | function onScroll() { 42 | allImages.each(function(i, img) { 43 | img = $(img) 44 | var h = img.height() 45 | var top = img.offset().top 46 | var bottom = top + h 47 | 48 | var viewBegin = document.scrollingElement.scrollTop 49 | var viewEnd = viewBegin + window.outerHeight 50 | viewBegin -= 100 51 | viewEnd += 100 52 | var isVisible = top > viewBegin && top < viewEnd 53 | || bottom > viewBegin && bottom < viewEnd 54 | || top <= viewBegin && bottom >= viewEnd; 55 | 56 | var oldVisibility = img.css('visibility'); 57 | var newVisibility = isVisible ? 'visible' : 'hidden'; 58 | if (oldVisibility != newVisibility) { 59 | img.css('visibility', newVisibility) 60 | } 61 | }) 62 | } 63 | $(onScroll); 64 | 65 | window.addEventListener( 66 | 'scroll', 67 | _.throttle(onScroll, 80, {leading: false, trailing: true}), 68 | ); 69 | })() 70 | 71 | var intermediateValNotFunc = function () { 72 | var FLAG_COOKIE = 'noGithubEngage'; 73 | var NUM_DAYS_COOKIE = 'disableGithubCounterDays'; 74 | 75 | function getCookie(cname) { 76 | var name = cname + "="; 77 | var decodedCookie = decodeURIComponent(document.cookie); 78 | var ca = decodedCookie.split(';'); 79 | for(var i = 0; i 4 |
    5 |
    6 |
    7 |
    8 |
    9 | 10 |
    11 |
    12 |
    13 | 18 |
    19 |
    20 |
    21 | Run 22 |
    23 |
    24 |
    25 |
    26 | 27 |
    28 |
    29 |
    30 | 31 | Editing query... 32 | 33 |
    34 |
    35 |
    36 | 37 |
    38 | 39 |
    40 |
    41 |
    {{ .Inner }}
    42 | 43 |
    44 | 45 |
    46 | 47 |
    48 | 49 |
    50 |
    curl localhost:8080/query -XPOST -d '
     51 | {{ .Inner }}' | python -m json.tool | less
    52 |
    53 | 54 |
    55 |
    import io.dgraph.client.DgraphClient;
     56 | import io.dgraph.client.GrpcDgraphClient;
     57 | import io.dgraph.client.DgraphResult;
     58 | 
     59 | public class DgraphMain {
     60 |   public static void main(final String[] args) {
     61 |     final DgraphClient dgraphClient = GrpcDgraphClient.newInstance("localhost", 8080);
     62 |     final DgraphResult result = dgraphClient.query("{{ .Inner }}");
     63 |     System.out.println(result.toJsonObject().toString());
     64 |   }
     65 | }
    66 |
    67 |
    68 | 69 | 84 |
    85 |
    86 | 87 |
    88 |
    89 |
    90 |
    91 | 92 | Response 93 | 94 |
    95 |
    96 | 97 |
    98 |
    99 |
    100 | 101 | 119 | 120 |
    121 |
    122 |
    123 |
    124 | 125 | -------------------------------------------------------------------------------- /layouts/partials/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{ if eq .Permalink "/" }} 15 | {{ .Title }} 16 | 17 | 18 | {{ else }} 19 | {{ .Title }} - {{ .Site.Title }} 20 | 21 | 22 | {{ end }} 23 | 24 | 25 | {{ with .Description }}{{ end }} 26 | {{ with .Params.image }}{{ end }} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 42 | 43 | 44 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 67 | 70 | 71 | 72 | {{ if .IsPage }} 73 | {{ with .Params.image }} 74 | 75 | 76 | {{ else }} 77 | 78 | {{ end }} 79 | {{ else }} 80 | 81 | 82 | {{ end }} 83 | 84 | 85 | 86 | {{ with .Site.Params.twitter }}{{ end }} 87 | 88 | -------------------------------------------------------------------------------- /layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 | 66 | 67 | 68 | 71 | 74 | 75 | {{ if .Site.Params.keenIoProjectId }} 76 | 77 | 90 | {{ end }} 91 | 92 | {{ if .Site.Params.countlyKey }} 93 | 114 | {{ end }} 115 | 116 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /exampleSite/static/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 20 | 21 | 26 | 38 | 40 | 47 | 57 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /static/css/runnable.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS for runnable component 3 | * 4 | * IF USED IN BLOG, DO NOT MODIFY - To make it easier to share runnable with the 5 | * docs, write any custom CSS rules in runnable-custom.css 6 | * 7 | * All CSS rules except for the latency tooltip is scoped to class or id 8 | * specific to runnable. 9 | * 10 | * Runnable CSS depends on bootstrap 4 alpha.6 for responsive grid 11 | */ 12 | 13 | .runnable pre { 14 | position: relative; 15 | padding: 1rem; 16 | transition: all 300ms cubic-bezier(0.175, 0.885, 0.335, 1.05); 17 | margin: 2rem 0; 18 | background: #f9f9f9; 19 | border: 0; 20 | border-radius: 2px; 21 | line-height: 1.45; 22 | border: 1px solid #ececec; 23 | } 24 | .runnable pre code { 25 | /*color: #237794;*/ 26 | background: inherit; 27 | white-space: inherit; 28 | border: 0; 29 | padding: 0; 30 | margin: 0; 31 | white-space: pre-wrap; 32 | white-space: -moz-pre-wrap; 33 | white-space: -pre-wrap; 34 | white-space: -o-pre-wrap; 35 | word-wrap: break-word; 36 | font-size: 90%; 37 | } 38 | 39 | .runnable { 40 | background: #ffffff; 41 | padding: 29px 0px; 42 | margin-bottom: 13px; 43 | } 44 | .runnable .runnable-pane { 45 | margin: 0px 2px 4px 0; 46 | padding: 3px; 47 | border: 1px solid #ececec; 48 | background: #f9f9f9; 49 | height: 326px; 50 | display: flex; 51 | flex-direction: column; 52 | } 53 | .runnable .runnable-content { 54 | flex: 1; 55 | background-repeat: no-repeat; 56 | background-position: center; 57 | background-color: #fff; 58 | display: flex; 59 | flex-direction: column; 60 | overflow-y: auto; 61 | } 62 | .runnable .topbar { 63 | /*overflow: auto;*/ 64 | /*padding: 4px 17px 4px 18px;*/ 65 | padding: 1px 0px 8px; 66 | } 67 | .runnable .footer { 68 | padding: 4px 0; 69 | } 70 | .runnable .output { 71 | overflow-y: auto; 72 | background: #fffff3; 73 | } 74 | .runnable .code-btn:hover { 75 | text-decoration: none; 76 | color: inherit; 77 | } 78 | .runnable .code-btn[data-action='run'], 79 | .runnable .code-btn[data-action='save'] { 80 | background-color: #3e65b7; 81 | color: white; 82 | } 83 | .runnable .code-btn[data-action='run']:hover { 84 | background-color: white; 85 | color: #3e65b7; 86 | border: 1px solid #3e65b7; 87 | } 88 | .runnable .output-container.empty { 89 | visibility: hidden; 90 | } 91 | .runnable .output-container:not(.empty) { 92 | visibility: visible; 93 | } 94 | .runnable .output-container.error code { 95 | color: #bf0000; 96 | } 97 | .runnable .nav-languages { 98 | padding-left: 4px; 99 | } 100 | .runnable .nav-languages .language { 101 | font-size: 14px; 102 | color: #373e42; 103 | display: inline-block; 104 | padding: 0 8px 0 7px; 105 | text-decoration: none; 106 | } 107 | .runnable .nav-languages .language.active { 108 | color: #0094de; 109 | } 110 | .CodeMirror { 111 | font-size: 80%; 112 | height: auto; 113 | z-index: 0; 114 | } 115 | .CodeMirror-lines { 116 | background: #fffff3; 117 | } 118 | .runnable.editing .normal-actions { 119 | display: none; 120 | } 121 | .runnable:not(.editing) .edit-actions { 122 | display: none; 123 | } 124 | .runnable.editing [data-action="expand"] { 125 | display: none; 126 | } 127 | .runnable .runnable-code { 128 | background: #fffff3; 129 | overflow-y: auto; 130 | } 131 | .runnable .latency-info { 132 | display: inline-block; 133 | font-size: 13px; 134 | padding-left: 5px; 135 | } 136 | .runnable .latency-info .stat { 137 | display: inline-block; 138 | color: gray; 139 | padding-right: 5px; 140 | } 141 | .runnable .latency-info .number { 142 | color: #3e65b7; 143 | font-weight: 600; 144 | } 145 | .runnable .pane-title { 146 | vertical-align: middle; 147 | padding: 0px 13px; 148 | display: inline-block; 149 | } 150 | .runnable .latency-info { 151 | vertical-align: middle; 152 | } 153 | html .runnable pre { 154 | padding: 0; 155 | border: 0; 156 | margin: 0; 157 | background: inherit; 158 | } 159 | html .runnable code { 160 | padding: 17px 12px; 161 | } 162 | .runnable .runnable-tab-content:not(.active) { 163 | display: none; 164 | } 165 | .runnable:not(.editing) .editing-header { 166 | display: none; 167 | } 168 | .runnable.editing .normal-header { 169 | display: none; 170 | } 171 | 172 | #runnable-modal { 173 | background: rgba(0, 0, 0, 0.63); 174 | } 175 | #runnable-modal .modal-title { 176 | margin: 0; 177 | } 178 | #runnable-modal .runnable { 179 | padding: 0; 180 | margin-bottom: 0; 181 | } 182 | #runnable-modal .runnable-pane { 183 | height: 77vh; 184 | } 185 | #runnable-modal .code-btn[data-action='expand'] { 186 | display: none; 187 | } 188 | #runnable-modal .modal-close-btn { 189 | top: 19px; 190 | right: 33px; 191 | position: absolute; 192 | color: white; 193 | padding-bottom: 1px; 194 | border-bottom: 1px solid white; 195 | line-height: 19px; 196 | letter-spacing: 1px; 197 | font-size: 16px; 198 | } 199 | #runnable-modal .modal-close-btn:hover { 200 | color: #afafaf; 201 | border-color: #afafaf; 202 | text-decoration: none; 203 | } 204 | @media screen and (min-width: 1024px) { 205 | #runnable-modal .modal-dialog { 206 | max-width: 80%; 207 | margin-top: 69px; 208 | } 209 | } 210 | @media screen and (min-width: 768px) and (max-width: 1024px) { 211 | #runnable-modal .runnable { 212 | padding: 23px 0; 213 | } 214 | #runnable-modal .modal-dialog { 215 | max-width: 90%; 216 | margin-top: 69px; 217 | } 218 | } 219 | @media screen and (max-width: 768px) { 220 | #runnable-modal .modal-dialog { 221 | max-width: 100%; 222 | margin: 58px 9px; 223 | } 224 | #runnable-modal .modal-close-btn { 225 | font-size: 13px; 226 | } 227 | #runnable-modal .runnable-pane { 228 | height: 50vh; 229 | } 230 | } 231 | @media screen and (min-width: 1441px) { 232 | #runnable-modal .runnable-pane { 233 | height: 84vh; 234 | } 235 | } 236 | @media screen and (max-width: 375px) { 237 | #runnable-modal .modal-dialog { 238 | margin-left: 0; 239 | margin-right: 0; 240 | } 241 | } 242 | .latency-tooltip-container { 243 | font-size: 11px; 244 | } 245 | .latency-tooltip-container .measurement-row { 246 | overflow: auto; 247 | width: 117px; 248 | } 249 | .latency-tooltip-container .measurement-key { 250 | display: inline-block; 251 | float: left; 252 | } 253 | .latency-tooltip-container .measurement-key.total { 254 | font-weight: 600; 255 | } 256 | .latency-tooltip-container .measurement-val { 257 | display: inline-block; 258 | float: right; 259 | font-weight: 600; 260 | } 261 | .latency-tooltip-container .divider { 262 | width: 100%; 263 | border-bottom: 1px solid white; 264 | margin: 2px 0 3px; 265 | } 266 | 267 | .runnable .code-btn { 268 | color: #5a5a5a; 269 | background: white; 270 | padding: 6px 12px 6px; 271 | text-transform: uppercase; 272 | font-size: 11px; 273 | letter-spacing: 0.5px; 274 | border: 1px solid #ececec; 275 | cursor: pointer; 276 | /*display: inline-block;*/ 277 | } 278 | .runnable .code-btn.active { 279 | background: #E0EBF5; 280 | } 281 | 282 | 283 | /* custom bootstrap */ 284 | /*.row-no-padding [class^="col-"] { 285 | padding-left: 0 !important; 286 | padding-right: 0 !important; 287 | }*/ 288 | .runnable .nopadding { 289 | padding: 0 !important; 290 | margin: 0 !important; 291 | } 292 | .runnable .hidden { 293 | display: none !important; 294 | } 295 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /static/css/heart.scss: -------------------------------------------------------------------------------- 1 | @import "compass"; 2 | 3 | // Config 4 | $size: 10em; 5 | $animDuration: 1s; 6 | $animTiming: ease-in; 7 | $animIteration: 1; 8 | $animStep: 100% / 27; 9 | 10 | // Layers & Colors 11 | $heartColors: #AAB8C2, #E2264D; 12 | $ringColors: #E2264D, #CC8EF5; 13 | $circles: ( 14 | ( 15 | first: ( start: #8CE8C3, end:#A068CE), 16 | second: ( start: #8BE7C2, end:#B752E1) 17 | ), 18 | ( 19 | first: ( start: #90D2FA, end:#99E9C8), 20 | second: ( start: #91D1F9, end:#BAE3D7) 21 | ), 22 | ( 23 | first: ( start: #CC8EF5, end:#D3F491), 24 | second: ( start: #CB8DF4, end:#DCE483) 25 | ), 26 | ( 27 | first: ( start: #8CE8C3, end:#59C392), 28 | second: ( start: #8CE8C3, end:#67CD9F) 29 | ), 30 | ( 31 | first: ( start: #F58EA7, end:#CAADC7), 32 | second: ( start: #F48DA6, end:#959FF3) 33 | ), 34 | ( 35 | first: ( start: #91D2FA, end:#CA5ED8), 36 | second: ( start: #91D2FA, end:#A975D1) 37 | ), 38 | ( 39 | first: ( start: #92D3FC, end:#C35DD1), 40 | second: ( start: #CB8DF4, end:#90E0BE) 41 | ) 42 | ); 43 | 44 | // Computations 45 | $circlesLength: length($circles); 46 | $angleBetweenCircles: 360deg / $circlesLength; 47 | $circleSize: $size / 6; 48 | $shiftAngleBeginning: -135deg; 49 | 50 | // Functions 51 | @function setStep($n) { @return ($n - 1) * $animStep } 52 | 53 | @function setBoxShadow($distance1, $distance2, $size1, $size2, $shiftAngle, $colorRatio) { 54 | $boxS: (); 55 | 56 | @for $i from 1 through length($circles) { 57 | $circle: nth($circles, $i); 58 | $order: $i - 1; 59 | $angle1: ($order * $angleBetweenCircles) + $shiftAngleBeginning; 60 | $angle2: $angle1 + $shiftAngle; 61 | $distanceRatio1: $size * $distance1; 62 | $distanceRatio2: $size * $distance2; 63 | $firstCircle: map-get($circle, first); 64 | $firstCircleStart: map-get($firstCircle, start); 65 | $firstCircleEnd: map-get($firstCircle, end); 66 | $secondCircle: map-get($circle, second); 67 | $secondCircleStart: map-get($secondCircle, start); 68 | $secondCircleEnd: map-get($secondCircle, end); 69 | 70 | $boxS: append($boxS, 71 | cos($angle1) * $distanceRatio1 72 | sin($angle1) * $distanceRatio1 73 | 0 74 | $circleSize * $size1 75 | mix($firstCircleStart, $firstCircleEnd, $colorRatio) 76 | ); 77 | 78 | $boxS: append($boxS, 79 | cos($angle2) * $distanceRatio2 80 | sin($angle2) * $distanceRatio2 81 | 0 82 | $circleSize * $size2 83 | mix($secondCircleStart, $secondCircleEnd, $colorRatio) 84 | ); 85 | } 86 | 87 | @return join($boxS, (), "comma"); 88 | } 89 | 90 | // Animations 91 | @keyframes heart { 92 | #{setStep(1)}, 93 | #{setStep(6)} { 94 | height: 0; 95 | width: 0; 96 | top: 50%; 97 | margin-top: 0; 98 | margin-left: 0; 99 | } 100 | #{setStep(13)} { 101 | height: $size * 1.25; 102 | width: $size * 1.25; 103 | top: 54%; 104 | margin-top: -$size * 1.25 / 2; 105 | margin-left: -$size * 1.25 / 2; 106 | } 107 | #{setStep(18)}{ 108 | height: $size; 109 | width: $size; 110 | top: 54%; 111 | margin-top: -$size / 2; 112 | margin-left: -$size / 2; 113 | } 114 | #{setStep(23)} { 115 | height: $size * 1.025; 116 | width: $size * 1.025; 117 | top: 54%; 118 | margin-top: -$size * 1.025 / 2; 119 | margin-left: -$size * 1.025 / 2; 120 | } 121 | #{setStep(28)}{ 122 | height: $size; 123 | width: $size; 124 | top: 54%; 125 | margin-top: -$size / 2; 126 | margin-left: -$size / 2; 127 | } 128 | } 129 | 130 | @keyframes ring { 131 | #{setStep(1)} { 132 | height: 0; 133 | width: 0; 134 | border-width: 0; 135 | margin-top: 0; 136 | margin-left: 0; 137 | } 138 | #{setStep(2)} { 139 | height: 0; 140 | width: 0; 141 | border-width: $size * 0.1; 142 | margin-top: -$size * 0.1; 143 | margin-left: -$size * 0.1; 144 | border-color: nth($ringColors, 1); 145 | } 146 | #{setStep(3)} { 147 | height: 0; 148 | width: 0; 149 | border-width: $size * 0.7; 150 | margin-top: -$size * 0.7; 151 | margin-left: -$size * 0.7; 152 | } 153 | #{setStep(4)} { 154 | height: 0; 155 | width: 0; 156 | border-width: $size * 0.8; 157 | margin-top: -$size * 0.8; 158 | margin-left: -$size * 0.8; 159 | } 160 | #{setStep(5)} { 161 | height: 0; 162 | width: 0; 163 | border-width: $size * 0.85; 164 | margin-top: -$size * 0.85; 165 | margin-left: -$size * 0.85; 166 | } 167 | #{setStep(6)} { 168 | width: $size * 1.2; 169 | height: $size * 1.2; 170 | border-width: $size * 0.25; 171 | border-color: nth($ringColors, 2); 172 | } 173 | #{setStep(7)} { 174 | width: $size * 1.6; 175 | height: $size * 1.6; 176 | border-width: $size * 0.05; 177 | } 178 | #{setStep(8)}, 179 | #{setStep(28)} { 180 | width: $size * 1.7; 181 | height: $size * 1.7; 182 | border-width: 0; 183 | margin-top: -$size * 0.85; 184 | margin-left: -$size * 0.85; 185 | } 186 | } 187 | 188 | @keyframes circles { 189 | #{setStep(1)}, 190 | #{setStep(6)} { 191 | box-shadow: setBoxShadow($distance1: 0.75, $distance2: 0.75, $size1: -0.500, $size2: -0.500, $colorRatio: 100%, $shiftAngle: -5deg); 192 | } 193 | #{setStep(7)} { 194 | box-shadow: setBoxShadow($distance1: 0.80, $distance2: 0.85, $size1: -0.200, $size2: -0.200, $colorRatio: 100%, $shiftAngle: -5deg); 195 | } 196 | #{setStep(15)} { 197 | box-shadow: setBoxShadow($distance1: 1.20, $distance2: 1.00, $size1: -0.100, $size2: -0.350, $colorRatio: 25%, $shiftAngle: -12deg); 198 | } 199 | #{setStep(23)}, 200 | #{setStep(28)} { 201 | box-shadow: setBoxShadow($distance1: 1.20, $distance2: 1.00, $size1: -0.500, $size2: -0.500, $colorRatio: 0%, $shiftAngle: -12deg); 202 | } 203 | } 204 | 205 | // Styles 206 | .heart-wrapper{ 207 | height: $size * 3; 208 | width: $size * 3; 209 | position: relative; 210 | cursor:pointer; 211 | 212 | // Layer 1 : Heart 213 | .heart{ 214 | display: block; 215 | height: $size; 216 | width: $size; 217 | top: 54%; 218 | margin-top: -$size / 2; 219 | margin-left: -$size / 2; 220 | left: 50%; 221 | position: absolute; 222 | z-index: 0; 223 | 224 | > * { 225 | overflow: hidden; 226 | position: absolute; 227 | &:after{ 228 | display: block; 229 | content: ''; 230 | position: absolute; 231 | background: nth($heartColors, 1); 232 | } 233 | } 234 | 235 | // Top Left Part 236 | .tl{ 237 | height: 25%; 238 | width: 50.25%; 239 | top: 0; 240 | left: 0; 241 | &:after{ 242 | top: 0; 243 | left: 0; 244 | height: 200%; 245 | width: 104%; 246 | border-top-left-radius: 70% 80%; 247 | border-top-right-radius: 80% 80%; 248 | border-bottom-right-radius: 50% 50%; 249 | border-bottom-left-radius: 50% 50%; 250 | } 251 | } 252 | 253 | // Top Right Part 254 | .tr{ 255 | height: 25%; 256 | width: 50.25%; 257 | top: 0; 258 | right: 0; 259 | &:after{ 260 | top: 0; 261 | right: 0; 262 | height: 200%; 263 | width: 104%; 264 | border-top-left-radius: 80% 80%; 265 | border-top-right-radius: 70% 80%; 266 | border-bottom-right-radius: 50% 50%; 267 | border-bottom-left-radius: 50% 50%; 268 | } 269 | } 270 | 271 | // Bottom Left Part 272 | .bl{ 273 | height: 75.5%; 274 | width: 50.25%; 275 | bottom: 0; 276 | left: 0; 277 | &:after{ 278 | top: 0; 279 | left: 0; 280 | height: 95%; 281 | width: 160%; 282 | border-top-left-radius: 0 0; 283 | border-top-right-radius: 0 0; 284 | border-bottom-right-radius: 0 0; 285 | border-bottom-left-radius: 100% 100%; 286 | } 287 | } 288 | 289 | // Bottom Right Part 290 | .br{ 291 | height: 75.5%; 292 | width: 50.25%; 293 | bottom: 0; 294 | right: 0; 295 | &:after{ 296 | top: 0; 297 | right: 0; 298 | height: 95%; 299 | width: 160%; 300 | border-top-left-radius: 0 0; 301 | border-top-right-radius: 0 0; 302 | border-bottom-right-radius: 100% 100%; 303 | border-bottom-left-radius: 0 0; 304 | } 305 | } 306 | } 307 | 308 | // Layer 2 : Ring 309 | .ring{ 310 | display: block; 311 | position: absolute; 312 | border-width: 0; 313 | border-style: solid; 314 | top: 50%; 315 | left: 50%; 316 | border-radius: 50%; 317 | z-index: 1; 318 | } 319 | 320 | // Layer 3 : Circles 321 | .circles{ 322 | display: block; 323 | position: absolute; 324 | height: $circleSize; 325 | width: $circleSize; 326 | top: 50%; 327 | left: 50%; 328 | margin-top: -$circleSize / 2; 329 | margin-left: -$circleSize / 2; 330 | z-index: 2; 331 | border-radius: 50%; 332 | } 333 | 334 | // Hover Styles 335 | &:hover .heart{ 336 | .tl,.tr,.bl,.br{ 337 | &:after{ 338 | background: nth($heartColors, 2); 339 | } 340 | } 341 | } 342 | 343 | // Active Styles 344 | &.active{ 345 | 346 | // Layer 1 : Animation 347 | .heart{ 348 | animation-name: heart; 349 | animation-duration: $animDuration; 350 | animation-timing-function: $animTiming; 351 | animation-iteration-count: $animIteration; 352 | .tl,.tr,.bl,.br{ 353 | &:after{ 354 | background: nth($heartColors, 2); 355 | } 356 | } 357 | } 358 | 359 | // Layer 2 : Animation 360 | .ring{ 361 | animation-name: ring; 362 | animation-duration: $animDuration; 363 | animation-timing-function: $animTiming; 364 | animation-iteration-count: $animIteration; 365 | } 366 | 367 | // Layer 3 : Animation 368 | .circles{ 369 | animation-name: circles; 370 | animation-duration: $animDuration; 371 | animation-timing-function: $animTiming; 372 | animation-iteration-count: $animIteration; 373 | } 374 | } 375 | } 376 | -------------------------------------------------------------------------------- /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 `