21 |
--------------------------------------------------------------------------------
/exampleSite/content/about/_index.md:
--------------------------------------------------------------------------------
1 | +++
2 | date = "2015-06-20T14:02:37+02:00"
3 | title = "About"
4 | hidden = true
5 | menu = "main"
6 | +++
7 |
8 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa ullam earum dolorum! Sed, perspiciatis.
9 |
10 | Lorem ipsum dolor sit amet, consectetur adipisicing elit.
11 |
12 | ***
13 |
14 | ### Lorem ipsum dolor.
15 |
16 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea dicta corporis ad inventore itaque impedit dolor atque amet exercitationem! Veniam qui voluptas maiores vel laudantium necessitatibus, velit ducimus! Iste hic facere, accusamus fugiat enim facilis.
17 |
--------------------------------------------------------------------------------
/layouts/partials/pagination.html:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/static/js/main.js:
--------------------------------------------------------------------------------
1 | // To make images retina, add a class "2x" to the img element
2 | // and add a @2x.png image. Assumes jquery is loaded.
3 |
4 | function isRetina() {
5 | var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\
6 | (min--moz-device-pixel-ratio: 1.5),\
7 | (-o-min-device-pixel-ratio: 3/2),\
8 | (min-resolution: 1.5dppx)";
9 |
10 | if (window.devicePixelRatio > 1)
11 | return true;
12 |
13 | if (window.matchMedia && window.matchMedia(mediaQuery).matches)
14 | return true;
15 |
16 | return false;
17 | };
18 |
19 |
20 | function retina() {
21 |
22 | if (!isRetina())
23 | return;
24 |
25 | $("img.2x").map(function(i, image) {
26 |
27 | var path = $(image).attr("src");
28 |
29 | path = path.replace(".png", "@2x.png");
30 | path = path.replace(".jpg", "@2x.jpg");
31 |
32 | $(image).attr("src", path);
33 | });
34 | };
35 |
36 | $(document).ready(retina);
--------------------------------------------------------------------------------
/theme.toml:
--------------------------------------------------------------------------------
1 | name = "Cactus"
2 | license = "MIT"
3 | licenselink = "https://github.com/digitalcraftsman/hugo-cactus-theme/blob/master/License.md"
4 | description = "A minimalistic and responsive theme for bloggers."
5 | homepage = "https://github.com/digitalcraftsman/hugo-cactus-theme"
6 | tags = ["blog", "disqus", "google analytics", "rss", "syntax highlighting"]
7 | features = ["disqus", "google analytics", "rss", "syntax highlighting", "blog", "pagination", "sharing options"]
8 | min_version = 0.20
9 |
10 | [author]
11 | name = "digitalcraftsman"
12 | homepage = "//github.com/digitalcraftsman"
13 |
14 | [[original]]
15 | # Ported the stardard theme of the Cactus for Mac static site generator to Jekyll
16 | name = "Nick Balestra"
17 | homepage = "http://nick.balestra.ch/"
18 | repo = "https://github.com/nickbalestra/kactus"
19 |
20 | [[original]]
21 | # Original creators of the stardard theme for the Cactus for Mac static site generator
22 | name = "Cactus for Mac authors"
23 | homepage = "http://cactusformac.com"
24 | repo = "https://github.com/koenbok/Cactus"
25 |
--------------------------------------------------------------------------------
/static/css/monosocialiconsfont.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'Mono Social Icons Font';
3 | src: url('../fonts/MonoSocialIconsFont-1.10.eot');
4 | src: url('../fonts/MonoSocialIconsFont-1.10.eot?#iefix') format('embedded-opentype'),
5 | url('../fonts/MonoSocialIconsFont-1.10.woff') format('woff'),
6 | url('../fonts/MonoSocialIconsFont-1.10.ttf') format('truetype'),
7 | url('../fonts/MonoSocialIconsFont-1.10.svg#MonoSocialIconsFont') format('svg');
8 | src: url('../fonts/MonoSocialIconsFont-1.10.ttf') format('truetype');
9 | font-weight: normal;
10 | font-style: normal;
11 | }
12 |
13 | .symbol, a.symbol:before {
14 | font-family: 'Mono Social Icons Font';
15 | -webkit-text-rendering: optimizeLegibility;
16 | -moz-text-rendering: optimizeLegibility;
17 | -ms-text-rendering: optimizeLegibility;
18 | -o-text-rendering: optimizeLegibility;
19 | text-rendering: optimizeLegibility;
20 | -webkit-font-smoothing: antialiased;
21 | -moz-font-smoothing: antialiased;
22 | -ms-font-smoothing: antialiased;
23 | -o-font-smoothing: antialiased;
24 | font-smoothing: antialiased;
25 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 [Cactus Authors](//github.com/koenbok/Cactus/blob/master/AUTHORS), [Nick Balestra](//github.com/nickbalestra) and [digitalcraftsman](//github.com/digitalcraftsman)
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/_default/single.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 |
3 |
4 |
{{ .Title }}
5 |
{{ .Description | markdownify }}
6 |
7 | {{ .Date.Format "January 2, 2006" }}
8 |
9 | {{ with .Params.tags }}
10 | {{ if ge (len .) 1 }}
11 | {{ range . }}
12 | {{ . }}
13 | {{ end }}
14 | {{ end }}
15 | {{ end}}
16 |
17 |
18 |
19 | {{ .Content }}
20 |
21 |
22 |
23 |
35 |
36 | {{ template "_internal/disqus.html" . }}
37 |
38 | {{ partial "latest-posts.html" . }}
39 | {{ end }}
40 |
--------------------------------------------------------------------------------
/layouts/partials/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ with .Site.Params.name }}{{ end }}
5 | {{ with .Site.Params.description }}{{ end }}
6 | {{ hugo.Generator }}
7 | {{ .Title }}{{ if .IsHome }} · {{ .Site.Title }}{{ end }}
8 |
9 |
10 |
11 | {{ range .Site.Params.customCSS }}
12 |
13 | {{ end }}
14 |
15 | {{ if eq .Site.Params.iconFont "font-awesome" }}
16 |
17 | {{ else }}
18 |
19 | {{ end }}
20 |
21 | {{ if .Site.Params.enableRSS }}
22 |
23 | {{ end }}
24 |
25 | {{ template "_internal/opengraph.html" . }}
26 | {{ template "_internal/google_news.html" . }}
27 | {{ template "_internal/schema.html" . }}
28 | {{ template "_internal/twitter_cards.html" . }}
29 |
--------------------------------------------------------------------------------
/exampleSite/config.toml:
--------------------------------------------------------------------------------
1 | # Site settings
2 | baseurl = "https://example.org/"
3 | themesDir = "../.."
4 | languageCode = "en-us"
5 | title = "Hugo Cactus Theme"
6 | theme = "hugo-cactus-theme"
7 | # Enter your tracking code to enable Google Analytics
8 | googleAnalytics = ""
9 | # Disable comments by leaving disqusShortname empty
10 | disqusShortname = "spf13"
11 |
12 | [params]
13 | name = "John Doe"
14 | description = "Describe your website"
15 | bio = "Blogger & Programmer"
16 | # Enter optionally your twitter account
17 | twitter = "Your Twitter account"
18 | enableRSS = true
19 |
20 | # Integrate Javascript files or stylesheets by adding the url to the external assets or by
21 | # linking local files with their path relative to the static folder, e.g. "css/styles.css"
22 | customCSS = []
23 | customJS = []
24 |
25 | # The variables below are optionally too and can be used to
26 | # translate or customize each string of the theme.
27 |
28 | # Navigation links
29 | home = ""
30 | subscribe = ""
31 | # Pagination links
32 | olderPosts = ""
33 | newerPosts = ""
34 | readMore = ""
35 | copyright = ""
36 | # Sharing options and author information in posts
37 | aboutAuthor = "I'm an blogger."
38 | tweet = ""
39 | share = ""
40 | # 404 page
41 | title404 = ""
42 | subtitle404 = ""
43 |
44 | # Choose a font for the social icons in the footer. Either "mono-social" or "font-awesome"
45 | iconFont = "mono-social"
46 | # The social icons can be styled differently if you use mono as font - circle, rounded, or empty
47 | socialIconStyle = "circle"
48 |
49 | # Add additional social link entries underneath
50 | [social]
51 | twitter = "https://www.twitter.com/"
52 | facebook = "https://www.facebook.com/"
53 | github = "https://www.github.com/"
54 | dribble = "https://www.dribbble.com/"
55 |
--------------------------------------------------------------------------------
/static/css/highlight.css:
--------------------------------------------------------------------------------
1 | /*
2 | IR_Black style (c) Vasily Mikhailitchenko
3 | */
4 |
5 | .hljs {
6 | display: block;
7 | overflow-x: auto;
8 | /*padding: 0.5em;*/
9 | background: #272b2d;
10 | color: #d0d0d0;
11 | -webkit-text-size-adjust: none;
12 | }
13 |
14 | .hljs-shebang,
15 | .hljs-comment {
16 | color: #777279;
17 | }
18 |
19 | .hljs-keyword,
20 | .hljs-tag,
21 | .tex .hljs-command,
22 | .hljs-request,
23 | .hljs-status,
24 | .clojure .hljs-attribute {
25 | color: #ebde68;
26 | }
27 |
28 | .hljs-sub .hljs-keyword,
29 | .method,
30 | .hljs-list .hljs-title,
31 | .nginx .hljs-title {
32 | color: #ffffb6;
33 | }
34 |
35 | .hljs-string,
36 | .hljs-tag .hljs-value,
37 | .hljs-cdata,
38 | .hljs-filter .hljs-argument,
39 | .hljs-attr_selector,
40 | .apache .hljs-cbracket,
41 | .hljs-date,
42 | .coffeescript .hljs-attribute {
43 | color: #c1ef65;
44 | }
45 |
46 | .hljs-subst {
47 | color: #daefa3;
48 | }
49 |
50 | .hljs-regexp {
51 | color: #e9c062;
52 | }
53 |
54 | .hljs-title,
55 | .hljs-sub .hljs-identifier,
56 | .hljs-pi,
57 | .hljs-decorator,
58 | .tex .hljs-special,
59 | .hljs-type,
60 | .hljs-constant,
61 | .smalltalk .hljs-class,
62 | .hljs-doctag,
63 | .nginx .hljs-built_in {
64 | color: #c1ef65;
65 | }
66 |
67 | .hljs-symbol,
68 | .ruby .hljs-symbol .hljs-string,
69 | .hljs-number,
70 | .hljs-variable,
71 | .vbscript,
72 | .hljs-literal,
73 | .hljs-name {
74 | color: #77bcd7;
75 | }
76 |
77 | .css .hljs-tag {
78 | color: #96cbfe;
79 | }
80 |
81 | .css .hljs-rule .hljs-property,
82 | .css .hljs-id {
83 | color: #ffffb6;
84 | }
85 |
86 | .css .hljs-class {
87 | color: #fff;
88 | }
89 |
90 | .hljs-hexcolor {
91 | color: #c6c5fe;
92 | }
93 |
94 | .hljs-number {
95 | color:#77bcd7;
96 | }
97 |
98 | .coffeescript .javascript,
99 | .javascript .xml,
100 | .tex .hljs-formula,
101 | .xml .javascript,
102 | .xml .vbscript,
103 | .xml .css,
104 | .xml .hljs-cdata {
105 | opacity: 0.7;
106 | }
107 |
108 |
--------------------------------------------------------------------------------
/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 | +++
16 |
17 | ## Step 1. Install Hugo
18 |
19 | Goto [hugo releases](https://github.com/spf13/hugo/releases) and download the
20 | appropriate version for your os and architecture.
21 |
22 | Save it somewhere specific as we will be using it in the next step.
23 |
24 | More complete instructions are available at [installing hugo](/overview/installing/)
25 |
26 | ## Step 2. Build the Docs
27 |
28 | Hugo has its own example site which happens to also be the documentation site
29 | you are reading right now.
30 |
31 | Follow the following steps:
32 |
33 | 1. Clone the [hugo repository](http://github.com/spf13/hugo)
34 | 2. Go into the repo
35 | 3. Run hugo in server mode and build the docs
36 | 4. Open your browser to http://localhost:1313
37 |
38 | Corresponding pseudo commands:
39 |
40 | git clone https://github.com/spf13/hugo
41 | cd hugo
42 | /path/to/where/you/installed/hugo server --source=./docs
43 | > 29 pages created
44 | > 0 tags index created
45 | > in 27 ms
46 | > Web Server is available at http://localhost:1313
47 | > Press ctrl+c to stop
48 |
49 | Once you've gotten here, follow along the rest of this page on your local build.
50 |
51 | ## Step 3. Change the docs site
52 |
53 | Stop the Hugo process by hitting ctrl+c.
54 |
55 | Now we are going to run hugo again, but this time with hugo in watch mode.
56 |
57 | /path/to/hugo/from/step/1/hugo server --source=./docs --watch
58 | > 29 pages created
59 | > 0 tags index created
60 | > in 27 ms
61 | > Web Server is available at http://localhost:1313
62 | > Watching for changes in /Users/spf13/Code/hugo/docs/content
63 | > Press ctrl+c to stop
64 |
65 |
66 | Open your [favorite editor](http://vim.spf13.com) and change one of the source
67 | content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
68 |
69 | Content files are found in `docs/content/`. Unless otherwise specified, files
70 | are located at the same relative location as the url, in our case
71 | `docs/content/overview/quickstart.md`.
72 |
73 | Change and save this file.. Notice what happened in your terminal.
74 |
75 | > Change detected, rebuilding site
76 |
77 | > 29 pages created
78 | > 0 tags index created
79 | > in 26 ms
80 |
81 | Refresh the browser and observe that the typo is now fixed.
82 |
83 | Notice how quick that was. Try to refresh the site before it's finished building.. I double dare you.
84 | Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
85 |
86 | ## Step 4. Have fun
87 |
88 | The best way to learn something is to play with it.
89 |
--------------------------------------------------------------------------------
/static/fonts/icons.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cactus Theme
2 |
3 | Cactus is a minimalistic theme for bloggers based on the default theme of the same-named [Cactus static site generator](//github.com/koenbok/Cactus) written in Python and [Nick Balestra](//github.com/nickbalestra/kactus)'s Jekyll port. Noteworthy features of this Hugo theme are the integration of a comment-system powered by Disqus, a customizable about page, support for RSS feeds, syntax highlighting for source code, and sharing options for blog posts.
4 |
5 | ### Please note that this theme is no longer maintained.
6 | *A fork of this theme can be found at [github.com/nodejh/hugo-theme-cactus-plus](https://github.com/nodejh/hugo-theme-cactus-plus)*
7 |
8 |
9 | 
10 |
11 |
12 | ## Installation
13 |
14 | Inside the folder of your Hugo site, run:
15 |
16 | $ cd themes
17 | $ git clone https://github.com/digitalcraftsman/hugo-cactus-theme.git
18 |
19 | For more information, please read Hugo's official [setup guide](//gohugo.io/overview/installing/).
20 |
21 | ### The config file
22 |
23 | Take a look inside the [`exampleSite`](//github.com/digitalcraftsman/hugo-cactus-theme/tree/dev/exampleSite) folder of this theme. You'll find a file called [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml).
24 |
25 | To use it, copy the [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml) file to the root folder of your Hugo site. Feel free to change the strings as you like to customize your website.
26 |
27 | Make sure to update the `themesDir` property in the config file to point to your site's theme folder, otherwise an error will be thrown indicating the themes folder is unable to be found.
28 |
29 | ## About page
30 |
31 | Use the about page to introduce yourself to your visitors. You can customize the content as you like in the [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml). Furthermore, you should replace the [avatar placeholder](//github.com/digitalcraftsman/hugo-cactus-theme/blob/master/static/images/avatar.png) with a great image of yourself.
32 |
33 | ## Disqus
34 |
35 | This theme features a comment system powered by Disqus too. Just add your Disqus-shortname to the [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml) and let readers respond to your blog posts.
36 |
37 | ## Social link icons
38 |
39 | You can add a social link panel in the footer by adding entries to the `social` block in the [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml). You can choose between two icon fonts:
40 |
41 | - [Font awesome](https://fortawesome.github.io/Font-Awesome/) or
42 | - [Mono social icons](https://github.com/drinchev/monosocialiconsfont)
43 |
44 | Assign either `font-awesome` or `mono-social` to the `iconFont` variable. The Mono social icons offer three styles of icons: circle, rounded, or default (empty).
45 |
46 | ## Nearly finished
47 |
48 | To see your site in action, run Hugo's built-in local server.
49 |
50 | $ hugo server
51 |
52 | Now enter [`localhost:1313`](http://localhost:1313) in the address bar of your browser.
53 |
54 |
55 | ## Contributing
56 |
57 | Found a bug or got an idea for a new feature? Feel free to use the [issue tracker](//github.com/digitalcraftsman/hugo-cactus-theme/issues) to let me know. Or directly make a [pull request](//github.com/digitalcraftsman/hugo-cactus-theme/pulls).
58 |
59 | Please create a separate branch for your pull request.
60 |
61 |
62 | ## License
63 |
64 | This theme is released under the MIT license. For more information read the [license](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/LICENSE.md).
65 |
66 |
67 | ## Acknowledgements
68 |
69 | Thanks to
70 |
71 | - [Nick Balestra](//github.com/nickbalestra/kactus) for creating the original theme
72 | - [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project.
73 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Release v1.1.1 - 04th September 2017
4 |
5 |
6 | - [6f818c5](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/6f818c506139debad3188d3bb027ca6808d9577d) Ordered lists are now styled
7 | - [9fb2a23](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/9fb2a23ab32fb61b62a77e9e8d590ab2cddb8201) adds support for subtitles in pages that can be defined with `.Description` in the front matter
8 | -[a0db308](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/a0db30812aafc89cde5a77d3189f3a028fabe5ba) widens the content column to improve the readability of code examples
9 | - [5108c87](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/5108c8787408d4d31a9161bb47cc506fd2d01fc6) loads FontAwesome from Bootstrap's CDN instead of using the local file.
10 |
11 |
12 | ## Release v1.1 - 26th April 2017
13 |
14 | *In the future new additions and changes will be assigned to version numbers rather than dates.* This allows you to track changes in a better fashion. The state of this theme before this release has been assigned to v1.0.
15 |
16 | **Some changes and additions listed below require Hugo v0.20 or higher.** Consider to update Hugo to a newer as well if necessary.
17 |
18 | ### Fixes:
19 |
20 | [34f8cf2](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/34f8cf2)q fixes display issues of the about page that occured in Hugo v0.18 and higher due to the way how Hugo treats sites as a page of different kinds. **It's required to rename `content/about/index.md` to `content/about/_index.md`**.
21 |
22 | ### Improvements
23 |
24 | - [931eb53](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/931eb53) improves the generation URLs and linkage of pages
25 | - [9b358a9](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/9b358a9) uses block templates to reduce redundancy
26 | - [dd67ac4](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/dd67ac4) adds support for linking pages in the main menu
27 |
28 | ### Deprecations
29 |
30 | - [fa3c87d](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/fa3c87d) replaces .Now which was deprecated in Hugo v0.19
31 | - [c618828](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/c618828) deprecates the `params.about` config option
32 | - [1b6b863](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/1b6b863) deprecates the option to hide single pages with the `hidden = true` front matter option. Use `draft = true` instead
33 |
34 |
35 | ## 4th January 2016
36 |
37 | ### Fontawesome as option for social icons in footer
38 |
39 | You can now use Fontawesome as alternative to the Mono social icons. Look [here](https://github.com/digitalcraftsman/hugo-cactus-theme/tree/dev#social-link-icons) for more instructions.
40 |
41 | [Show me the diff](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/79e5435d6be25ae882ab5ae8455f17834f109a32)
42 |
43 | ### Hide pages
44 |
45 | Pages can now be hidden by adding `hidden = true` to the frontmatter. The pages are still built but they will not appear in the post in on the homepage.
46 |
47 | [Show me the diff](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/cf93e42859280b04703cd6ca96062db9a4adb65e)
48 |
49 |
50 | ## 7th December 2015
51 |
52 | ### Social link icons
53 |
54 | Social links with icons can be enabled replacing the copyright field in footer. Configure the style and links in `config.toml`.
55 |
56 | ## 26th November 2015
57 |
58 | Hugo v0.15 is required in order to run the theme with the changes listed below:
59 |
60 | ### Google Analytics
61 |
62 | The setup of Google Analytics changed slighty due to the switch to Hugo's built-in template. In order to update the theme you need to relocate the `google_analytics` variable in the configs and rename it to `googleAnalytics`. Take a look in the example [`config.toml`](https://github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml).
63 |
64 | [Show me the diff](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/c2cdd9a02a968738438c48d246ae3949a4e032fc)
65 |
66 |
67 | ### Disqus
68 |
69 | Now the theme uses the built-in template of Hugo to enable the comments section with Disqus. This change requires to relocate the `disqusShortname` variable in the configs.
70 |
71 | [Show me the diff](https://github.com/digitalcraftsman/hugo-cactus-theme/commit/9ebf05f5b03b3a60fc11cc47775234b7fc2616f0)
72 |
--------------------------------------------------------------------------------
/exampleSite/content/post/migrate-from-jekyll.md:
--------------------------------------------------------------------------------
1 | ---
2 | date: 2014-03-10
3 | linktitle: Migrating from Jekyll
4 | title: Migrate to Hugo from Jekyll
5 | ---
6 |
7 | ## Move static content to `static`
8 | Jekyll has a rule that any directory not starting with `_` will be copied as-is to the `_site` output. Hugo keeps all static content under `static`. You should therefore move it all there.
9 | With Jekyll, something that looked like
10 |
11 | ▾ /
12 | ▾ images/
13 | logo.png
14 |
15 | should become
16 |
17 | ▾ /
18 | ▾ static/
19 | ▾ images/
20 | logo.png
21 |
22 | Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
23 |
24 | ## Create your Hugo configuration file
25 | 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.
26 |
27 | ## Set your configuration publish folder to `_site`
28 | 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:
29 |
30 | 1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
31 |
32 | git submodule deinit _site
33 | git rm _site
34 | git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
35 |
36 | 2. Or, change the Hugo configuration to use `_site` instead of `public`.
37 |
38 | {
39 | ..
40 | "publishdir": "_site",
41 | ..
42 | }
43 |
44 | ## Convert Jekyll templates to Hugo templates
45 | 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.
46 |
47 | As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
48 |
49 | ## Convert Jekyll plugins to Hugo shortcodes
50 | Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
51 |
52 | ### Implementation
53 | 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.
54 |
55 | Jekyll's plugin:
56 |
57 | ```ruby
58 | module Jekyll
59 | class ImageTag < Liquid::Tag
60 | @url = nil
61 | @caption = nil
62 | @class = nil
63 | @link = nil
64 | // Patterns
65 | IMAGE_URL_WITH_CLASS_AND_CAPTION =
66 | IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
67 | IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
68 | IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
69 | IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
70 | def initialize(tag_name, markup, tokens)
71 | super
72 | if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
73 | @class = $1
74 | @url = $3
75 | @caption = $7
76 | @link = $9
77 | elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
78 | @class = $1
79 | @url = $3
80 | @caption = $7
81 | elsif markup =~ IMAGE_URL_WITH_CAPTION
82 | @url = $1
83 | @caption = $5
84 | elsif markup =~ IMAGE_URL_WITH_CLASS
85 | @class = $1
86 | @url = $3
87 | elsif markup =~ IMAGE_URL
88 | @url = $1
89 | end
90 | end
91 | def render(context)
92 | if @class
93 | source = ""
94 | else
95 | source = ""
96 | end
97 | if @link
98 | source += ""
99 | end
100 | source += ""
101 | if @link
102 | source += ""
103 | end
104 | source += "#{@caption}" if @caption
105 | source += ""
106 | source
107 | end
108 | end
109 | end
110 | Liquid::Template.register_tag('image', Jekyll::ImageTag)
111 | ```
112 |
113 | is written as this Hugo shortcode:
114 |
115 |
116 |
117 | {{ with .Get "link"}}{{ end }}
118 |
119 | {{ if .Get "link"}}{{ end }}
120 | {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
121 | {{ if isset .Params "title" }}
122 | {{ .Get "title" }}{{ end }}
123 | {{ if or (.Get "caption") (.Get "attr")}}
{{ end }}
129 |
130 | {{ end }}
131 |
132 |
133 |
134 | ### Usage
135 | I simply changed:
136 |
137 | {% 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/ %}
138 |
139 | to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`):
140 |
141 | {{%/* 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/" */%}}
142 |
143 | As a bonus, the shortcode named parameters are, arguably, more readable.
144 |
145 | ## Finishing touches
146 | ### Fix content
147 | 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.
148 |
149 | ### Clean up
150 | You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
151 |
152 | ## A practical example in a diff
153 | [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).
154 |
--------------------------------------------------------------------------------
/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 | +++
17 |
18 | Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for
19 | its template engine. It is an extremely lightweight engine that provides a very
20 | small amount of logic. In our experience that it is just the right amount of
21 | logic to be able to create a good static website. If you have used other
22 | template systems from different languages or frameworks you will find a lot of
23 | similarities in go templates.
24 |
25 | This document is a brief primer on using go templates. The [go docs][gohtmltemplate]
26 | provide more details.
27 |
28 | ## Introduction to Go Templates
29 |
30 | Go templates provide an extremely simple template language. It adheres to the
31 | belief that only the most basic of logic belongs in the template or view layer.
32 | One consequence of this simplicity is that go templates parse very quickly.
33 |
34 | A unique characteristic of go templates is they are content aware. Variables and
35 | content will be sanitized depending on the context of where they are used. More
36 | details can be found in the [go docs][gohtmltemplate].
37 |
38 | ## Basic Syntax
39 |
40 | Go lang templates are html files with the addition of variables and
41 | functions.
42 |
43 | **Go variables and functions are accessible within {{ }}**
44 |
45 | Accessing a predefined variable "foo":
46 |
47 | {{ foo }}
48 |
49 | **Parameters are separated using spaces**
50 |
51 | Calling the add function with input of 1, 2:
52 |
53 | {{ add 1 2 }}
54 |
55 | **Methods and fields are accessed via dot notation**
56 |
57 | Accessing the Page Parameter "bar"
58 |
59 | {{ .Params.bar }}
60 |
61 | **Parentheses can be used to group items together**
62 |
63 | {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
64 |
65 |
66 | ## Variables
67 |
68 | Each go template has a struct (object) made available to it. In hugo each
69 | template is passed either a page or a node struct depending on which type of
70 | page you are rendering. More details are available on the
71 | [variables](/layout/variables) page.
72 |
73 | A variable is accessed by referencing the variable name.
74 |
75 | {{ .Title }}
76 |
77 | Variables can also be defined and referenced.
78 |
79 | {{ $address := "123 Main St."}}
80 | {{ $address }}
81 |
82 |
83 | ## Functions
84 |
85 | Go template ship with a few functions which provide basic functionality. The go
86 | template system also provides a mechanism for applications to extend the
87 | available functions with their own. [Hugo template
88 | functions](/layout/functions) provide some additional functionality we believe
89 | are useful for building websites. Functions are called by using their name
90 | followed by the required parameters separated by spaces. Template
91 | functions cannot be added without recompiling hugo.
92 |
93 | **Example:**
94 |
95 | {{ add 1 2 }}
96 |
97 | ## Includes
98 |
99 | When including another template you will pass to it the data it will be
100 | able to access. To pass along the current context please remember to
101 | include a trailing dot. The templates location will always be starting at
102 | the /layout/ directory within Hugo.
103 |
104 | **Example:**
105 |
106 | {{ template "chrome/header.html" . }}
107 |
108 |
109 | ## Logic
110 |
111 | Go templates provide the most basic iteration and conditional logic.
112 |
113 | ### Iteration
114 |
115 | Just like in go, the go templates make heavy use of range to iterate over
116 | a map, array or slice. The following are different examples of how to use
117 | range.
118 |
119 | **Example 1: Using Context**
120 |
121 | {{ range array }}
122 | {{ . }}
123 | {{ end }}
124 |
125 | **Example 2: Declaring value variable name**
126 |
127 | {{range $element := array}}
128 | {{ $element }}
129 | {{ end }}
130 |
131 | **Example 2: Declaring key and value variable name**
132 |
133 | {{range $index, $element := array}}
134 | {{ $index }}
135 | {{ $element }}
136 | {{ end }}
137 |
138 | ### Conditionals
139 |
140 | If, else, with, or, & and provide the framework for handling conditional
141 | logic in Go Templates. Like range, each statement is closed with `end`.
142 |
143 |
144 | Go Templates treat the following values as false:
145 |
146 | * false
147 | * 0
148 | * any array, slice, map, or string of length zero
149 |
150 | **Example 1: If**
151 |
152 | {{ if isset .Params "title" }}
{{ index .Params "title" }}
{{ end }}
153 |
154 | **Example 2: If -> Else**
155 |
156 | {{ if isset .Params "alt" }}
157 | {{ index .Params "alt" }}
158 | {{else}}
159 | {{ index .Params "caption" }}
160 | {{ end }}
161 |
162 | **Example 3: And & Or**
163 |
164 | {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
165 |
166 | **Example 4: With**
167 |
168 | An alternative way of writing "if" and then referencing the same value
169 | is to use "with" instead. With rebinds the context `.` within its scope,
170 | and skips the block if the variable is absent.
171 |
172 | The first example above could be simplified as:
173 |
174 | {{ with .Params.title }}
{{ . }}
{{ end }}
175 |
176 | **Example 5: If -> Else If**
177 |
178 | {{ if isset .Params "alt" }}
179 | {{ index .Params "alt" }}
180 | {{ else if isset .Params "caption" }}
181 | {{ index .Params "caption" }}
182 | {{ end }}
183 |
184 | ## Pipes
185 |
186 | One of the most powerful components of go templates is the ability to
187 | stack actions one after another. This is done by using pipes. Borrowed
188 | from unix pipes, the concept is simple, each pipeline's output becomes the
189 | input of the following pipe.
190 |
191 | Because of the very simple syntax of go templates, the pipe is essential
192 | to being able to chain together function calls. One limitation of the
193 | pipes is that they only can work with a single value and that value
194 | becomes the last parameter of the next pipeline.
195 |
196 | A few simple examples should help convey how to use the pipe.
197 |
198 | **Example 1 :**
199 |
200 | {{ if eq 1 1 }} Same {{ end }}
201 |
202 | is the same as
203 |
204 | {{ eq 1 1 | if }} Same {{ end }}
205 |
206 | It does look odd to place the if at the end, but it does provide a good
207 | illustration of how to use the pipes.
208 |
209 | **Example 2 :**
210 |
211 | {{ index .Params "disqus_url" | html }}
212 |
213 | Access the page parameter called "disqus_url" and escape the HTML.
214 |
215 | **Example 3 :**
216 |
217 | {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
218 | Stuff Here
219 | {{ end }}
220 |
221 | Could be rewritten as
222 |
223 | {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
224 | Stuff Here
225 | {{ end }}
226 |
227 |
228 | ## Context (aka. the dot)
229 |
230 | The most easily overlooked concept to understand about go templates is that {{ . }}
231 | always refers to the current context. In the top level of your template this
232 | will be the data set made available to it. Inside of a iteration it will have
233 | the value of the current item. When inside of a loop the context has changed. .
234 | will no longer refer to the data available to the entire page. If you need to
235 | access this from within the loop you will likely want to set it to a variable
236 | instead of depending on the context.
237 |
238 | **Example:**
239 |
240 | {{ $title := .Site.Title }}
241 | {{ range .Params.tags }}
242 |
243 | {{ end }}
244 |
245 | Notice how once we have entered the loop the value of {{ . }} has changed. We
246 | have defined a variable outside of the loop so we have access to it from within
247 | the loop.
248 |
249 | # Hugo Parameters
250 |
251 | Hugo provides the option of passing values to the template language
252 | through the site configuration (for sitewide values), or through the meta
253 | data of each specific piece of content. You can define any values of any
254 | type (supported by your front matter/config format) and use them however
255 | you want to inside of your templates.
256 |
257 |
258 | ## Using Content (page) Parameters
259 |
260 | In each piece of content you can provide variables to be used by the
261 | templates. This happens in the [front matter](/content/front-matter).
262 |
263 | An example of this is used in this documentation site. Most of the pages
264 | benefit from having the table of contents provided. Sometimes the TOC just
265 | doesn't make a lot of sense. We've defined a variable in our front matter
266 | of some pages to turn off the TOC from being displayed.
267 |
268 | Here is the example front matter:
269 |
270 | ```
271 | ---
272 | title: "Permalinks"
273 | date: "2013-11-18"
274 | aliases:
275 | - "/doc/permalinks/"
276 | groups: ["extras"]
277 | groups_weight: 30
278 | notoc: true
279 | ---
280 | ```
281 |
282 | Here is the corresponding code inside of the template:
283 |
284 | {{ if not .Params.notoc }}
285 |