diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a05dad7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,73 @@ +# Changelog + +This changelog mainly documented some major changes, updates or fixes (with credits) for reference purposes. It by no means covers all contributors. Nonetheless, to the bottom of my heart, I truly appreciate all of your time and contributions. + +__2018-11__ + +* Per PR [#56](https://github.com/htr3n/hyde-hyde/commit/5ed13e17400bbc09a342b60fd50cd9fe3e6f1525), Gravatar pics can be used exclusively to `.Site.Params.authorimage` via the parameter `.Site.Params.social.gravatar` + + * ```toml + [params.social] + gravatar = "your.email@domain.com" + ``` + +* Fix Hugo demo (issue [#53](https://github.com/htr3n/hyde-hyde/issues/53)) + +* Fix mobile header (PR [#51](https://github.com/htr3n/hyde-hyde/pull/51): credits to [@gamingrobot](https://github.com/gamingrobot)) + +* Add Utterances comments (PR [#50](https://github.com/htr3n/hyde-hyde/pull/50): credits to [@gamingrobot](https://github.com/gamingrobot)) + +__2018-10__ + +* Enable `hyde-hyde` to work directly with SCSSs instead of generated CSSs (PR [#45](https://github.com/htr3n/hyde-hyde/pull/45): credits to [@jd4no](https://github.com/jd4no)) +* Patch potential vulnerabilities of `target="_blank"` (PR [#48](https://github.com/htr3n/hyde-hyde/pull/48): credits to [@gfrcsd](https://github.com/gfrcsd)) + +__2018-09__ + +* Add _Table of Contents_ + * Configure using `.Site.Params.toc` with two possible value: "hugo" (using Hugo `{{ .TableOfContents }}`, and "tocbot" (using [Tocbot](https://tscanlin.github.io/tocbot/)), remove `.Site.Params.toc` to disable TOC + * Change [_layouts/partials/header/styles.html_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/header/styles.html) to check `.Site.Params.toc` and add the corresponding styles + * Change [_layouts/partials/page-single/content.html_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/page-single/content.html ) to add TOC per `.Site.Params.toc` + * Add styles [_static-src/scss/hugo-toc.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.2/static-src/scss/hugo-toc.scss) and [_static-src/scss/tocbot.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.2/static-src/scss/tocbot.scss) that generate `hugo-toc.css` and `tocbot.css`, respectively + * Tocbot can be configured in [_layouts/partials/page-single/footer.html_](layouts/partials/page-single/footer.html) with options as described in [its documentation](https://tscanlin.github.io/tocbot/#api) + +__2018-07__ + +* Revise the shortcode ['fig.html'](https://github.com/htr3n/hyde-hyde/blob/master/layouts/shortcodes/fig.html) +* Rename `header/font-awesome.html` to `header/font-awesome-css.html` and adds [_footer/font-awesome-js.html_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/footer/font-awesome-js.html), uses Font-Awesome 5 deferred JavaScript loading to reduce CSS rendering blocking +* Refactor and consolidate all responsive breakpoints and creates a new style [_\_responsive.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.1/static-src/scss/hyde-hyde/_responsive.scss) +* Refactor portfolio's projects into [_\_project.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.1/static-src/scss/hyde-hyde/_project.scss) +* Refactor styles for a list of posts into [_\_list.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.1/static-src/scss/hyde-hyde/_list.scss) +* Refactor misc. styles into [_\_misc.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.1/static-src/scss/hyde-hyde/_misc.scss) +* Remove [_\_customised.scss_](https://github.com/htr3n/hyde-hyde/blob/v2.0.0/static-src/scss/hyde-hyde/_customised.scss) + +__Version 2.0__ + +* The main styles are refactored and redeveloped using SCSS (see [_static-src/scss_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/static-src/scss)) + and we no longer need `poole.css` and `hyde.css` because `hyde-hyde.scss` already incorporates relevant elements + * `Hyde-hyde` can be customised by changing SCSS styles in [_static-src/scss/hyde-hyde_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/static-src/scss/hyde-hyde) and layouts in [_layouts_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts) + * To generate `hyde-hyde.css`, please use any SCSS compiler to compile the main file `hyde-hyde.scss` +* Restructure/modularise further the layouts (see [_layouts_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts)) +* Add '[_Portfolio_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts/portfolio)' page inspired by Xiaoying Riley ([@3rdwave_themes](https://twitter.com/3rdwave_themes)) [Developer-Theme](https://github.com/xriley/developer-theme) +* Change the main body font to use system fonts (see [_\_variables.scss_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/static-src/scss/hyde-hyde/_variables.scss)) + * In case you prefer Web fonts, just include the template "[web-fonts.html](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts/partials/header/web-fonts.html)" to "[header.html](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts/partials/header.html)" +* Switch to main fixed width font [Source Code Pro](https://fonts.google.com/specimen/Source+Code+Pro) +* Add OpenGraph and TwitterCard templates (for SEO) +* Add '_Related Articles_' (see [_layouts/partials/post-related.html_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts/partials/post-related.html)) +* Add page navigation _NEXT / PREVIOUS_ +* Switch datetime format to `"Jan 02 '06"` in the list of posts (see [_layouts/partials/post-list.html_](https://github.com/htr3n/hyde-hyde/tree/v2.0.0/layouts/partials/post-list.html)) to save some space +* Change styles for links, tags, text +* Add some handy shortcodes for `` and `
` +* The License under '_Some Rights Reversed_' in the sidebar is switched from [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/) to [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). + +__Version 1.0__ + +* Color tones and layouts are inspired by [Nate Finch's blog](https://npf.io) +* Restructure/modularise the layouts (see [`layouts/_default/baseof.html`](https://github.com/htr3n/hyde-hyde/tree/v1.0.0/layouts/_default/baseof.html), [`layouts/_default/single.html`](https://github.com/htr3n/hyde-hyde/tree/v1.0.0/layouts/_default/single.html), [`layouts/_default/list.html`](https://github.com/htr3n/hyde-hyde/tree/v1.0.0/layouts/_default/list.html) and [`layouts/partials`](https://github.com/htr3n/hyde-hyde/tree/v1.0.0/layouts/partials/)) +* Use [highlight.js](https://highlightjs.org) for code highlighting +* Use [Font-Awesome 5](https://fontawesome.com)'s icons +* Use main font [Fira-Sans](https://fonts.google.com/specimen/Fira+Sans) + fixed width font [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono) +* Add [GraphComment](https://graphcomment.com) for replacing the built-in [Disqus](https://disqus.com) +* Fork from [Hyde](https://github.com/spf13/hyde) +* Refactor `basedof.html` and corresponding pages `index.html`, `single.html`, `list.html` + - define blocks `content` and `footer` that will be fulfilled by each different type of layout. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fa77ada --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +# Released under MIT License + +Copyright (c) 2018 Huy Tran. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 906c228..348e551 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,202 @@ -# hyde-decker +[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://github.com/htr3n/hyde-hyde/blob/master/LICENSE.md) ![GitHub release](https://img.shields.io/github/release/htr3n/hyde-hyde.svg) ![GitHub stars](https://img.shields.io/github/stars/htr3n/hyde-hyde.svg) ![GitHub forks](https://img.shields.io/github/forks/htr3n/hyde-hyde.svg) ![GitHub issues](https://img.shields.io/github/issues/htr3n/hyde-hyde.svg) ![GitHub issues closed](https://img.shields.io/github/issues-closed/htr3n/hyde-hyde.svg) -Fork of the Hugo theme hyde-hyde that introduces some necessary cleanup and changes. \ No newline at end of file +# Hyde-hyde + +__`Hyde-hyde`__ is a [Hugo](https://gohugo.io)'s theme inspired and derived from @spf13's [Hyde](https://github.com/spf13/hyde.git) and [Nate Finch's blog](https://npf.io). + +> NOTICE: Maintainers / collaborators seeking: As I'm underwater with my full time job at the moment, I'm actively looking for and welcome any new maintainers or collaborators. If you are interested, comment on [#130](https://github.com/htr3n/hyde-hyde/issues/130) and I can add you to the project. TIA. + +## Breaking Changes + +Since version 2.0, __`hyde-hyde`__ has been overhauled and, therefore, might cause some disruptions. + +* The main styles are refactored and redeveloped using SCSS (see [_assets/scss_](https://github.com/htr3n/hyde-hyde/blob/master/assets/scss)), `poole.css` and `hyde.css` are no longer needed because `hyde-hyde.scss` already incorporates relevant elements (I still keep them there for reference purpose) + * Per PR [#45 by [@jd4no](https://github.com/jd4no), `hyde-hyde` can use SCSSs directly in the templates instead of the generated CSSs. The generated CSSs and the generated resources are still kept in `hyde-hyde` in order to ensure the demo on [Hugo theme site](https://themes.gohugo.io) working. +* The layouts have been heavily restructured and modularised further (see [_layouts_](https://github.com/htr3n/hyde-hyde/blob/master/layouts)) +* Adding '[_Portfolio_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/portfolio)' page inspired by Xiaoying Riley (@3rdwave_themes) [Developer-Theme](https://github.com/xriley/developer-theme) +* Switching to use system fonts instead of Web fonts (e.g. privacy issues) +* Experimenting a collapsible menu in mobile mode +* Adding _Table of Contents_ + * Configure using `.Site.Params.toc` with two possible value: "hugo" (using Hugo `{{ .TableOfContents }}`, and "tocbot" (using [Tocbot](https://tscanlin.github.io/tocbot/)), remove `.Site.Params.toc` to disable TOC + * Tocbot can be configured in [layouts/partials/page-single/footer.html](layouts/partials/page-single/footer.html) with options as described in [its documentation](https://tscanlin.github.io/tocbot/#api) + +For more details, please refer to [CHANGELOG](https://github.com/htr3n/hyde-hyde/blob/master/CHANGELOG.md). A real site in action can be found [here](https://htr3n.github.io) and its [WIP source](https://github.com/htr3n/htr3n-blog) for reference. + +## Usage + +### Installation + +__`Hyde-hyde`__ can be easily installed as many other Hugo themes: + +```sh +$ cd HUGO_PROJECT + +# then either clone hyde-hyde +$ git clone https://github.com/htr3n/hyde-hyde.git themes/hyde-hyde + +# or just add hyde-hyde as a submodule +$ git submodule add https://github.com/htr3n/hyde-hyde.git themes/hyde-hyde +``` + +After that, choose `hyde-hyde` as the main theme. + +* `config.toml` + +```toml +theme = "hyde-hyde" +``` + +* `config.yaml` + +```yaml +theme : "hyde-hyde" +``` + +That's all. You can render your site using `hugo` and see `hyde-hyde` in action. + +### Options + +__`Hyde-hyde`__ essentially inherits most of Hyde's [options](https://github.com/spf13/hyde#options). There are some extra options though + +* `highlightjs = true`: use [highlight.js](https://highlightjs.org) instead of Hugo built-in support for code highlighting + + * `highlightjsstyle="highlight-style"`: only when `highlightjs = true`, please choose one of many _highlight.js_'s [styles](https://highlightjs.org/static/demo). + * Since [v2.0.1](https://github.com/htr3n/hyde-hyde/tree/v2.0.1), highlighting for each page can be fine-tuned in the front matter, for example + * `highlight = false` (default `true`) + * `highlightjslanguages = ["swift", "objectivec"]` + +* `postNavigation = true|false` (default `true`): Setting to `false` will disable the navigation _Previous Post_/ _Next Post_ + +* `relatedPosts = false|true` (default `false`): Setting to `true` allows related posts. Please refer [here](https://gohugo.io/content-management/related) for more details on related contents with Hugo. + +* `GraphCommentId = "your-graphcomment-id"`: to use [GraphComment](https://graphcomment.com) instead of the built-in [Disqus](https://disqus.com). This option should be used exclusively with `disqusShortname = "disqus-shortname"`. + +* `UtterancesRepo = "owner/repo-name"`: to use [Utterances](https://utteranc.es/) instead of the built-in [Disqus](https://disqus.com). This option should be used exclusively with `disqusShortname = "disqus-shortname"`. + * `UtterancesIssueTerm = "pathname"` Method for Utterances to match issue's to posts (pathname, url, title, og:title) + * `UtterancesTheme = "github-light"` Theme for Utterances (github-light, github-dark) + +* `Commento = true`: to use [Commento](https://commento.io/) instead of the built-in [Disqus](https://disqus.com). This option should be used exclusively with `disqusShortname = "disqus-shortname"`. + * `CommentoHost = "your-commento-instance"` [Self-hosted Commento](https://docs.commento.io/installation/self-hosting/) instance. This is not required if you're a [Commento.io](https://commento.io) user. + +* `[params.social]`: in this section, you can set many social identities such as Twitter, Facebook, Github, Bitbucket, Gitlab, Instagram, LinkedIn, StackOverflow, Medium, Xing, Keybase. + + ```toml + [params.social] + twitter = "htr3n" + keybase = "htr3n" + github = "htr3n" + ... + ``` + +* `include_toc = false`: Setting to `false` in FrontMatter will disable too short TOC data as your want. + + * Per PR [#56](https://github.com/htr3n/hyde-hyde/commit/5ed13e17400bbc09a342b60fd50cd9fe3e6f1525), Gravatar pics can be used exclusively to `.Site.Params.authorimage` via the parameter `.Site.Params.social.gravatar` + + * ```toml + [params.social] + gravatar = "your.email@domain.com" + ``` + +### Customisations + +* Most of the customisable SCSS styles in [_assets/scss/hyde-hyde_](https://github.com/htr3n/hyde-hyde/blob/master/assets/scss/hyde-hyde) and Hugo templates in [_hyde-hyde/layouts_](https://github.com/htr3n/hyde-hyde/blob/master/layouts) are modularised and can be altered/adapted easily. + +## Portfolio + +Since version 2.0+, I added a portfolio page just in case. If you need it, simply add a menu section '_Portfolio_' in `config.toml` as following. + +```toml +[[menu.main]] + name = "Portfolio" + identifier = "portfolio" + weight = xyz + url = "/portfolio/" +``` + +In the folder `content` , create a subfolder `portfolio` and use the following folder/content structure as reference. + +``` +$ tree portfolio +portfolio +├── _index.md +├── p1.md +├── p1.png +├── p2.md +├── p2.png + ... +├── pn.md +└── pn.png +``` + +As I design the section _portfolio_ to be rendered as _list_, `_index.md` can be used to set the title for your portfolio (you can read more about `_index.md` [here](https://gohugo.io/content-management/organization/#index-pages-index-md)). For instance, when I want to set the title of my portfolio "_Projects_", the front matter of `_index.md` will be: + +```markdown +--- +title: 'Projects' +--- +``` +The remaining of `_index.md` will be ignored. + +For each project, just create a Markdown file with the following parameters in the front matter: + +```markdown +--- +title: "Project P1's Title" +description: "A short description" +date: '2018-01-02' +link: 'https://project-p1.com' +screenshot: 'p1.png' +layout: 'portfolio' +featured: true +--- +Here is a longer summary of the project. You can write as long as you wish. +``` + +> __Note__: +> +> * `date` is important to sort the project chronologically +> * `layout 'portfolio'` is important as you don't want your project's page appear in the list of posts in the main page of your Web site but only in the _Portfolio_ ;) +> * `featured: true` : when you want to show a project as featured project. It is default to `false`. Note that only one project should be marked `featured: true` , otherwise, the result could be random as [the Hugo template](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/portfolio/content.html) will take the first one. +> * The body of the Markdown file will be the summary of the project. + +If you want to adjust the portfolio page to your needs, please have a look at the [main template](https://github.com/htr3n/hyde-hyde/blob/master/layouts/portfolio/list.html), that uses this [partial template](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/portfolio/content.html) and [this SCSS style](https://github.com/htr3n/hyde-hyde/blob/master/assets/scss/hyde-hyde/_project.scss). + +### Posts in home page +By default hugo will show in your home page the most populated section. +This means that if you have more projects than posts, by default your home page will list your projects instead of your posts. +If you want to change this behaviour you can change the [mainsections](https://gohugo.io/functions/where/#mainsections). +For example, for the [exampleSite](https://github.com/htr3n/hyde-hyde/tree/master/exampleSite) this is how you should change the `config.toml` file: +``` +[params] + mainSections = ["posts"] +``` + +## Some Screenshots + +### Main page + +![hyde-hyde main screen](https://github.com/htr3n/hyde-hyde/raw/master/images/main.png) + +### A post + +![A post in hyde-hyde](https://github.com/htr3n/hyde-hyde/raw/master/images/post.png) + +### Portfolio + +![Portfolio hyde-hyde](https://github.com/htr3n/hyde-hyde/raw/master/images/portfolio.png) + + + +### Mobile Mode with Collapsible Menu + +hyde-hyde in mobile mode + +## Author(s) + +* Original developed by [Mark Otto](https://github.com/mdo) + +* Hugo's `hyde` ported by [Steve Francia](https://github.com/spf13) + +## License + +Open sourced under the [MIT license](LICENSE.md) diff --git a/archetypes/blog.md b/archetypes/blog.md new file mode 100755 index 0000000..b000b66 --- /dev/null +++ b/archetypes/blog.md @@ -0,0 +1,16 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +description: "" +date: {{ .Date }} + +tags : [] +categories : [] + +layout: post +type: "post" + +draft: true + +slug: "" + +--- diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..ecda698 --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,23 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +date: {{ .Date }} +lastmod: {{ .Date }} +tags : [ "dev", "hugo", "hyde-hyde"] +categories : [ "dev" ] +layout: post +type: "post" +highlight: false +draft: true +--- + +**Insert Lead paragraph here.** + +A augue nunc lacus auctor efficitur tempor placerat, dictum volutpat mi vitae viverra porta non sem, himenaeos senectus vivamus potenti cubilia sollicitudin. Curae cursus inceptos tincidunt magna mi nibh ad enim etiam, molestie eu quis primis hendrerit taciti phasellus. Feugiat ultricies dictumst iaculis potenti odio laoreet urna at, ultrices curae leo accumsan proin sem lobortis. + +## Heading 2 + +Sollicitudin ornare odio blandit aenean enim lacus accumsan elementum vestibulum porta mauris lorem, ullamcorper class fermentum sem hendrerit ante augue penatibus scelerisque felis leo proin,ad nascetur venenatis sodales dignissim viverra suspendisse turpis convallis condimentum sapien. + +### Heading 3 + +At quisque litora ullamcorper maecenas ultricies ut dignissim luctus curabitur, cras congue eget primis aliquam fringilla nulla dictum posuere, vestibulum sit magnis nisl praesent eros ipsum nunc. Ligula lacus ipsum orci aenean integer pharetra habitasse interdum, porttitor etiam hac feugiat placerat morbi posuere turpis leo, quam at amet gravida commodo fringilla erat. diff --git a/assets/scss/hugo-toc.scss b/assets/scss/hugo-toc.scss new file mode 100644 index 0000000..8b2c657 --- /dev/null +++ b/assets/scss/hugo-toc.scss @@ -0,0 +1,43 @@ +// Hugo {{ .TableOfContents }} +$toc-background-color: #eee; +$toc-font-size: .9rem; + +.toc-wrapper { + font-size: $toc-font-size; + padding: 0.5em 0.5em 0.5em 0em; + background: $toc-background-color; + label { + background: url(/img/menu-close-dark.svg) no-repeat right center; + display: block; + cursor: pointer; + padding-left: 1em; + } +} +#TableOfContents { + overflow: hidden; + margin-top: 0; + max-height: 100%; + > ul { + list-style-type: none; + padding-left: 0; + > li ul { + list-style-type: none; + padding-left: 1em; + } + } +} + +input#tocToggle { + display: none; + + label { + font-weight: bold; + } + &:checked { + + label { + background-image: url(/img/menu-open-dark.svg); + } + ~ #TableOfContents { + max-height: 0; + } + } +} diff --git a/assets/scss/hyde-hyde.scss b/assets/scss/hyde-hyde.scss new file mode 100644 index 0000000..068fe46 --- /dev/null +++ b/assets/scss/hyde-hyde.scss @@ -0,0 +1,20 @@ +@import "hyde-hyde/variables"; +// poole +@import "poole/base"; +@import "poole/layout"; +@import "poole/posts"; +// hyde-hyde +@import 'hyde-hyde/mixins'; +@import 'hyde-hyde/base'; +@import 'hyde-hyde/sidebar'; +@import 'hyde-hyde/list'; +@import 'hyde-hyde/post'; +@import 'hyde-hyde/code'; +@import 'hyde-hyde/gist'; +@import 'hyde-hyde/navigation'; +@import 'hyde-hyde/taxonomies'; +@import 'hyde-hyde/project'; +@import 'hyde-hyde/responsive'; +@import 'hyde-hyde/misc'; +@import 'hyde-hyde/theme'; +@import 'hyde-hyde/blog'; diff --git a/assets/scss/hyde-hyde/_base.scss b/assets/scss/hyde-hyde/_base.scss new file mode 100644 index 0000000..8d217ff --- /dev/null +++ b/assets/scss/hyde-hyde/_base.scss @@ -0,0 +1,140 @@ +* { + box-sizing: border-box; +} + +html { + -webkit-text-size-adjust: 100%; // for iOS + box-direction: normal; + font-family: $root-font-family; + font-size: $small-device-font-size; + line-height: $root-line-height; + font-weight: $root-font-weight; +} + +html, body { + margin: 12; + padding: 0; +} + +h1, +h2, +h3, +h4 { + font-weight: $heading-font-weight; +} + +h1 { + font-size: $h1-font-size; + line-height: $h1-line-height; + margin-bottom: 1rem; +} + +h2 { + font-size: $h2-font-size; + margin-bottom: .5rem; +} + +h3 { + font-size: $h3-font-size; +} + +h4 { + font-size: $h4-font-size; +} + +h5 { + font-size: $h5-font-size; +} + +figure { + max-width: 100%; + margin: 0; + padding: 0; +} + +%quotebox { + padding: .8889rem; + margin-top: 1rem; + margin-left: 0px; + margin-right: 0px; + //border-radius: 6px; + border-left: 6px solid; + border-right: 6px solid transparent; + border-right-width: 6px; + border-right-style: solid; + border-right-color: rgba(0, 0, 0, 0) transparent; + color: #7a7a7a; +} + +blockquote { + background-color: #fafafa; + border-left-color: #e6e6e6; + @extend %quotebox; +} + +.important { + background-color: #fbf8e8; + border-left-color: #fee450; + @extend %quotebox; +} + +.warning { + background-color: #f2dbdc; + border-left-color: #ae272f; + @extend %quotebox; +} + +kbd { + font-family: $root-font-family; + padding: 2px 7px; + border: 1px solid $gray-4; + font-size: 0.8em; + line-height: 1.4; + background-color: #f3f3f3; + color: $gray-9; + box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 2px $white inset; + border-radius: 3px; + display: inline-block; + text-shadow: 0 1px 0 $white; + white-space: nowrap; +} + +a { + //border-bottom: 1px dotted; + color: $link-color; + text-decoration: none; + word-wrap: break-word; + &.sidebar-nav-item { + &:hover { + @include link-no-decoration(); + } + &:focus { + @include link-no-decoration(); + } + } + &:focus { + @include link-hover(); + &.tag { + @include link-no-decoration(); + } + } + &:hover { + @include link-hover(); + &.tag { + @include link-no-decoration(); + } + } + &.tag { + @include link-no-decoration(); + } + &.read-more-symbol { + text-decoration: none; + @include link-no-decoration(); + } +} + + +.content { + padding-bottom: 2rem; + padding-top: 2rem; +} diff --git a/assets/scss/hyde-hyde/_blog.scss b/assets/scss/hyde-hyde/_blog.scss new file mode 100644 index 0000000..5f57ca6 --- /dev/null +++ b/assets/scss/hyde-hyde/_blog.scss @@ -0,0 +1,93 @@ +.blog__content { + section { + margin-bottom: 1.765rem; + } +} + +.blog__featured-post { + margin: 0 0 1.765rem; + img { + margin: 0 0 1rem; + box-shadow: 1px 1px $gray-2; + } +} + +.blog__image { + border: 1px solid $gray-2; + box-shadow: 1px 1px $gray-2; +} + +.blog__title { + margin-top: 1.765rem; + letter-spacing: 1px; + font-size: $blog__title-font-size; +} + +%subtitle { + font-style: $blog__subtitle-font-style; + color: $blog__subtitle-color; + display: block; + margin-top: 0.5rem; + margin: 0 0 1rem; +} + +.blog__subtitle-big { + @extend %subtitle; + font-size: $blog__subtitle-font-size-big; +} + +.blog__subtitle-small { + @extend %subtitle; + font-size: $blog__subtitle-font-size-small; +} + +.blog__featured-image { + position: relative; +} + +.blog__summary { + margin-bottom: 1.765rem; + text-align: left; +} + +.divider { + margin-bottom: 3.5rem; +} +.row-space { + margin-bottom: 1rem; +} + +// only needs some pieces from Bootstrap +%col_extend { + min-height: 1px; + padding-left: 15px; + padding-right: 15px; + position: relative; +} + +.row { + margin-left: -15px; + margin-right: -15px; +} +.col-xs-12 { + width: 100%; + @extend %col_extend; +} +.col-sm-4 { + @extend %col_extend; +} +.col-md-4 { + @extend %col_extend; +} +.col-sm-8 { + @extend %col_extend; +} +.col-md-8 { + @extend %col_extend; +} + +.img-responsive { + display: block; + max-width: 100%; + height: auto; +} diff --git a/assets/scss/hyde-hyde/_code.scss b/assets/scss/hyde-hyde/_code.scss new file mode 100644 index 0000000..3940ed1 --- /dev/null +++ b/assets/scss/hyde-hyde/_code.scss @@ -0,0 +1,58 @@ +pre { + //border: 1px solid $gray-1; + //border-radius: 2px; + tab-size: 2; + //width: 111%; + //margin-left: -11%; + //padding-left: 9%; + //padding-right: 2%; + //background: #29292e; + code { + white-space: pre-wrap; + } +} + +%code-font { + font-family: $code-font-family; + font-size: $code-font-size; +} + +%code-in-rounded-box { + border-radius: 4px; + padding: 2px 4px; + color: #bf616a; + background-color: #f9f2f4; +} + +%code-style-codersblock { + padding: 2px 4px; + border: 1px dotted #adb5db; + background-color: $gray-1; +} + +%code-style-npf { + padding: .1em .1em; + color: #ab5979; + border-radius: 3px; +} + +a { + code { + color: $link-color; + } +} + +code { + @extend %code-font; + @extend %code-style-npf; +} + +// highlight.js +.hljs { + font-family: $code-font-family; + font-size: $code-fence-font-size; + line-height: $root-line-height; + white-space: pre; + border: 1px solid $gray-3; + border-radius: 4px; +} diff --git a/assets/scss/hyde-hyde/_gist.scss b/assets/scss/hyde-hyde/_gist.scss new file mode 100644 index 0000000..a572721 --- /dev/null +++ b/assets/scss/hyde-hyde/_gist.scss @@ -0,0 +1,56 @@ +// https://codersblock.com/blog/customizing-github-gists +/* +body .gist { + .gist-file { + margin-bottom: 0; + border-radius: 0; + } + .gist-data { + border-bottom: none; + border-radius: 0; + background-color: $gray-3; + } + .blob-wrapper { + border-radius: 0; + } + .highlight { + background-color: transparent; + font-family: Droid Sans Mono, monospace; + font-size: 14px; + td { + border: none; + padding: 5px 15px !important; + line-height: 1; + font-family: inherit; + font-size: inherit; + } + } + tr { + &:first-child td { + padding-top: 15px !important; + } + &:last-child td { + padding-bottom: 15px !important; + } + } + .blob-num { + color: #ced4da; + background-color: #495057; + pointer-events: none; + } + .gist-meta { + //display: none; + } +} +*/ +body .gist { + .gist-data { + background-color: $gray-0; + } + .highlight { + background-color: transparent; + } + td { + border: none; + } +} diff --git a/assets/scss/hyde-hyde/_list.scss b/assets/scss/hyde-hyde/_list.scss new file mode 100644 index 0000000..a5ef352 --- /dev/null +++ b/assets/scss/hyde-hyde/_list.scss @@ -0,0 +1,27 @@ +// for the list of posts + +.section__title { + font-size: $section__title-font-size; +} + +.post-list__item { + margin-bottom: 3em; +} + +.item__title--big { + display: block; + font-size: $item__title-big-font-size; + line-height: 1.25; +} + +.item__title--small { + font-size: 1rem; +} + +.item__date { + color: $item__date-color; + display: block; + font-size: $item__date-font-size; + margin-bottom: .2rem; + margin-top: .2rem; +} diff --git a/assets/scss/hyde-hyde/_misc.scss b/assets/scss/hyde-hyde/_misc.scss new file mode 100644 index 0000000..bf4de9f --- /dev/null +++ b/assets/scss/hyde-hyde/_misc.scss @@ -0,0 +1,25 @@ +// some misc styles +.element--center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.menu { + background-color: #f3f3f3; + color: #333; + border-radius: 2px; + padding: 1px 5px; +} + +.text-center { + text-align: center; +} + +.pull-right { + float: right; +} + +.draft { + color: #999 !important; +} diff --git a/assets/scss/hyde-hyde/_mixins.scss b/assets/scss/hyde-hyde/_mixins.scss new file mode 100644 index 0000000..2a7a2fe --- /dev/null +++ b/assets/scss/hyde-hyde/_mixins.scss @@ -0,0 +1,26 @@ +@mixin transform($string){ + -webkit-transform: $string; + -moz-transform: $string; + -ms-transform: $string; + -o-transform: $string; +} +@mixin rotate($deg){ + -webkit-transform: rotate($deg); + -moz-transform: rotate($deg); + -ms-transform: rotate($deg); + -o-transform: rotate($deg); +} + +@mixin link-no-decoration() { + border-style: none; + text-decoration: none; +} + +@mixin link-hover() { + color: $link-hover-color; + border-bottom: 1px dotted $gray-4; + text-decoration: none; + background: transparent; + background-color: transparent; + word-wrap: break-word; +} diff --git a/assets/scss/hyde-hyde/_navigation.scss b/assets/scss/hyde-hyde/_navigation.scss new file mode 100644 index 0000000..bef784a --- /dev/null +++ b/assets/scss/hyde-hyde/_navigation.scss @@ -0,0 +1,66 @@ +ul.pagination { + list-style: none; + li.page-item { + display: inline-block; + a { + padding: 0.05em 0.4em; + } + &.active { + a { + color: $navigation-color; + border-bottom: 3px solid $navigation-color; + } + } + } +} + +.navigation { + max-width: calc(100% - 0px); + margin: 0 auto; + margin-top: 60px; + a { + font-size: 0.8rem; + display: flex; + align-items: center; + justify-content: center; + padding: 15px; + color: $navigation-color; + border: 2px solid $navigation-color; + line-height: 1.25; + text-transform: uppercase; + &:hover { + padding: 14px; + border-width: 3px; + } + &:nth-child(2) { + margin-top: 10px; + } + &:first-child:last-child { + width: 100%; + } + } + .fa { + font-size: 0.8rem; + } + .navigation-prev { + text-align: left; + .fa { + padding-right: 10px; + } + .navigation-tittle { + padding-left: 4px; + } + } + .navigation-next { + text-align: right; + .fa { + padding-left: 10px; + } + .navigation-tittle { + padding-right: 4px; + } + } +} +.navigation-single a { + text-transform: none; +} diff --git a/assets/scss/hyde-hyde/_post.scss b/assets/scss/hyde-hyde/_post.scss new file mode 100644 index 0000000..5e3eb59 --- /dev/null +++ b/assets/scss/hyde-hyde/_post.scss @@ -0,0 +1,42 @@ +.post__meta { + font-size: $meta-font-size; + color: $meta-color; + font-weight: $meta-font-weight; +} + +.post__category { + font-weight: bold; +} + +.post__tag { + background: $tag-background-color; + border-radius: 2px; + color: $tag-color; + font-size: $tag-font-size; + font-weight: bold; + padding: 2px 6px; +} + +.post__title { + background-image: -webkit-linear-gradient(left, $gradient-color-1, $gradient-color-2); /* For Chrome and Safari */ + background-image: -moz-linear-gradient(left, $gradient-color-1, $gradient-color-2); /* For old Fx (3.6 to 15) */ + background-image: -ms-linear-gradient(left, $gradient-color-1, $gradient-color-2); /* For pre-releases of IE 10*/ + background-image: -o-linear-gradient(left, $gradient-color-1, $gradient-color-2); /* For old Opera (11.1 to 12.0) */ + background-image: linear-gradient(to right, $gradient-color-1, $gradient-color-2); /* Standard syntax; must be last */ + color:transparent; + -webkit-background-clip: text; + background-clip: text; + } + +.post__subtitle { + display: block; + font-size: $post__subtitle-font-size; + font-style: italic; + padding: 0 0 1rem 0; +} + +#references { + li { + font-size: 0.9rem; + } +} diff --git a/assets/scss/hyde-hyde/_print.scss b/assets/scss/hyde-hyde/_print.scss new file mode 100644 index 0000000..1be8310 --- /dev/null +++ b/assets/scss/hyde-hyde/_print.scss @@ -0,0 +1,53 @@ +@page { + margin: 1cm !important; +} +body { + font-size: $small-device-font-size; + line-height: 1.3; + background: #fff; + color: #000; +} + +.content { + margin: 0 auto; + width: 100%; + float: none; + display: initial; +} + +.container { + width: 100%; + float: none; + display: initial; + padding-left: 1rem; + padding-right: 1rem; + margin: 0 auto; +} +img { + max-width: 100%; +} +blockquote, +ul { + margin: 0; +} + +.sidebar { + display: none !important; +} + +.navigation { + display: none !important; +} + +.post__related { + display: none !important; +} + +.gist-meta { + display: none !important; +} + +#disqus_thread { + display: none !important; +} + diff --git a/assets/scss/hyde-hyde/_project.scss b/assets/scss/hyde-hyde/_project.scss new file mode 100644 index 0000000..d09c96a --- /dev/null +++ b/assets/scss/hyde-hyde/_project.scss @@ -0,0 +1,122 @@ +.portfolio__content { + section { + margin-bottom: 1.765rem; + } +} + +.portfolio__featured-project { + margin: 0 0 1.765rem; + img { + margin: 0 0 1rem; + box-shadow: 1px 1px $gray-2; + } +} + +.project__image { + border: 1px solid $gray-2; + box-shadow: 1px 1px $gray-2; +} + +.project__first-screen { + display: block; + margin-left: auto; + margin-right: auto; +} + +.project__additional-screens { + display: block; + margin-left: auto; + margin-right: auto; +} + +.project__single-screen { + display: inline-block; + width: 48%; +} + +.project__primary-screen { + width: 30%; + float: left; + margin-right: 1em; +} + + +.project__extra-screen { + float:left; + height:50% +} + +.project__title { + margin-top: 1.765rem; + letter-spacing: 1px; + font-size: $project__title-font-size; +} + +%subtitle { + font-style: $project__subtitle-font-style; + color: $project__subtitle-color; + display: block; + margin-top: 0.5rem; + margin: 0 0 1rem; +} + +.project__subtitle-big { + @extend %subtitle; + font-size: $project__subtitle-font-size-big; +} + +.project__subtitle-small { + @extend %subtitle; + font-size: $project__subtitle-font-size-small; +} + +.project__featured-image { + position: relative; +} + +.project__summary { + margin-bottom: 1.765rem; + text-align: left; +} + +.divider { + margin-bottom: 3.5rem; +} +.row-space { + margin-bottom: 1rem; +} + +// only needs some pieces from Bootstrap +%col_extend { + min-height: 1px; + padding-left: 15px; + padding-right: 15px; + position: relative; +} + +.row { + margin-left: -15px; + margin-right: -15px; +} +.col-xs-12 { + width: 100%; + @extend %col_extend; +} +.col-sm-4 { + @extend %col_extend; +} +.col-md-4 { + @extend %col_extend; +} +.col-sm-8 { + @extend %col_extend; +} +.col-md-8 { + @extend %col_extend; +} + +.img-responsive { + display: block; + max-width: 100%; + height: auto; +} diff --git a/assets/scss/hyde-hyde/_responsive.scss b/assets/scss/hyde-hyde/_responsive.scss new file mode 100644 index 0000000..e30d332 --- /dev/null +++ b/assets/scss/hyde-hyde/_responsive.scss @@ -0,0 +1,162 @@ +// mobile ~320..480px +// 320px ~ 16rem/16px ~ 18.8235/17px ~ 17.7778/18px +// 480px ~ 30rem/16px ~ 28.2353rem/17px ~ 26.6667rem/18px +@media (min-width: 320px) and (max-width: 767px) { + html, + body { + font-size: $small-device-font-size; + } + .sidebar { + li { + padding: .1rem 0; + } + .container { + padding-left: 0; + padding-right: 0; + } + } + .hidden-tablet { + display: none; + } + .sidebar-about, + .copyright { + display: none; + } + .sidebar { + margin: 0; + padding: 0; + } + .menu-content { + padding: 0 0 0 0px; + max-height: 0; + overflow: hidden; + margin-top: 0; } + .collapsible-menu { + padding: 0px 0px; + } + .collapsible-menu ul { + list-style-type: none; + padding: 0; + } + .collapsible-menu li { + display: block; + } + .collapsible-menu a { + text-decoration: none; + cursor: pointer; } + .collapsible-menu label { + background: url(/img/menu-open.svg) no-repeat left center; + background-position: 1.5rem; + display: block; + cursor: pointer; + color: #fff; + padding: 10px 0 10px 0px; } + + input#menuToggle { + display: none; + } + input#menuToggle + label { + font-weight: bold; + } + + input#menuToggle:checked + label { + background-image: url(/img/menu-close.svg); + background-position: 1.5rem; + color: #fff; + } + + input#menuToggle:checked ~ .menu-content { + max-height: 100% !important; + } + .social { + padding: 1em 0 1em 0; + } +} + +// tablet/medium device ~768px+ +// 768px ~ 48em/16px ~ 45.1765em/17px ~ 42.6667/18px +@media (min-width: 768px) { + html, + body { + font-size: $small-device-font-size; + } + .sidebar { + bottom: 0; + left: 0; + position: fixed; + text-align: left; + top: 0; + width: $sidebar-width; + } + .sidebar-sticky { + left: 1rem; + position: absolute; + right: 1rem; + top: 1rem; + } + .content { + margin-left: $content-margin-left; + margin-right: $content-margin-right; + max-width: $content-max-width; + } + .layout-reverse { + .sidebar { + left: auto; + right: 0; + } + .content { + margin-left: $content-margin-right; + margin-right: $content-margin-left; + } + } + .col-sm-8 { + width: 66.66666667%; + } + .project__title { + margin-top: 0.2rem; + } + .navigation { + display: flex; + justify-content: space-between; + a { + width: calc(50% - 10px); + &:nth-child(2) { + margin-top: 0; + } + } + } + input#menuToggle, + input#menuToggle + label { + display: none; + } +} + +// Large devices (laptops/desktops, 992px and up) +// ~ 62rem/16px ~ 58.3529rem/17px ~ 55.1111rem/18px +@media (min-width: 992px) { + html, + body { + font-size: $large-device-font-size; + } + .layout-reverse .content { + margin-left: 4rem; + margin-right: 22rem; + } + .col-md-4 { + float: left; + width: 33.33333333%; + } + .col-md-8 { + float: left; + width: 66.66666667%; + } + .portfolio-container { + width: 68rem; + } +} + +// Large device ~1024px +// 1024px ~ 64rem/16px ~ 60.2353rem/17px 56.8889rem/18px +@media (min-width: 1024px) { + // styles +} diff --git a/assets/scss/hyde-hyde/_sidebar.scss b/assets/scss/hyde-hyde/_sidebar.scss new file mode 100644 index 0000000..0686b42 --- /dev/null +++ b/assets/scss/hyde-hyde/_sidebar.scss @@ -0,0 +1,88 @@ +.sidebar { + background-color: $sidebar-color; + color: rgb(255, 255, 255); + color: rgba(255, 255, 255, 0.5); + padding: 2rem 1rem; + text-align: center; + a { + color: $gray-1; + border: none; + &:hover { + color: $link-color; + } + &:focus { + color: $link-color; + } + } + .sidebar-about { + text-align: center; + } + .author-image { + display: block; + margin-top: 4px; + } +} + +.sidebar-nav { + text-align: center; + list-style: none; + margin-bottom: 2rem; + margin-top: 2rem; + padding-left: 0; +} + +.sidebar-nav-item { + display: block; + line-height: 1.75; + .active { + font-weight: bold; + } +} +.site__title { + font-size: $site__title-font-size; + margin-bottom: 0.5rem; + a:hover { + border: none; + } +} + +.site__description { + font-size: 1.285rem; + font-weight: 300; +} + +.social { + text-align: center; + a { + padding: 0 4px; + @include link-no-decoration(); + } +} + +.img--circle { + border-radius: 50%; +} + +.img--headshot { + height: 115px; + width: 115px; +} + +.img--caption { + font-style: italic; +} + +%small-center-text { + font-size: $font-scale-dot7; + line-height: 1.1rem; + text-align: center; +} + +.copyright { + padding-top: 1rem; + @extend %small-center-text; +} +.builtwith { + padding-top: .2rem; + @extend %small-center-text; +} diff --git a/assets/scss/hyde-hyde/_taxonomies.scss b/assets/scss/hyde-hyde/_taxonomies.scss new file mode 100644 index 0000000..0de8d69 --- /dev/null +++ b/assets/scss/hyde-hyde/_taxonomies.scss @@ -0,0 +1,37 @@ +.badge-category, +a.badge-category { + color: #fff !important; + background-color: #0088cc; + &:hover, &:focus { + color: #0088cc !important; + background: transparent; + background-color: transparent; + text-decoration: none; + border-bottom: none; + } +} + +.badge-tag, +a.badge-tag { + color: #fff !important; + background-color: #7766cc; + &:hover, &:focus { + color: #7766cc !important; + background: transparent; + background-color: transparent; + text-decoration: none; + border-bottom: none; + } +} + +.badge { + display: inline-block; + padding: 0.25em 0.4em; + font-size: 0.75rem; + font-weight: bold; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: 0.25rem; +} diff --git a/assets/scss/hyde-hyde/_theme.scss b/assets/scss/hyde-hyde/_theme.scss new file mode 100644 index 0000000..195e822 --- /dev/null +++ b/assets/scss/hyde-hyde/_theme.scss @@ -0,0 +1,88 @@ +.theme-base-08 { + .sidebar { + background-color: #ac4142; + } + .content a { + color: #ac4142; + } + .related-posts li a:hover { + color: #ac4142; + } +} +.theme-base-09 { + .sidebar { + background-color: #d28445; + } + .content a { + color: #d28445; + } + .related-posts li a:hover { + color: #d28445; + } +} +.theme-base-0a { + .sidebar { + background-color: #f4bf75; + } + .content a { + color: #f4bf75; + } + .related-posts li a:hover { + color: #f4bf75; + } +} +.theme-base-0b { + .sidebar { + background-color: #90a959; + } + .content a { + color: #90a959; + } + .related-posts li a:hover { + color: #90a959; + } +} +.theme-base-0c { + .sidebar { + background-color: #75b5aa; + } + .content a { + color: #75b5aa; + } + .related-posts li a:hover { + color: #75b5aa; + } +} +.theme-base-0d { + .sidebar { + background-color: #6a9fb5; + } + .content a { + color: #6a9fb5; + } + .related-posts li a:hover { + color: #6a9fb5; + } +} +.theme-base-0e { + .sidebar { + background-color: #aa759f; + } + .content a { + color: #aa759f; + } + .related-posts li a:hover { + color: #aa759f; + } +} +.theme-base-0f { + .sidebar { + background-color: #8f5536; + } + .content a { + color: #8f5536; + } + .related-posts li a:hover { + color: #8f5536; + } +} \ No newline at end of file diff --git a/assets/scss/hyde-hyde/_variables.scss b/assets/scss/hyde-hyde/_variables.scss new file mode 100644 index 0000000..72d95fc --- /dev/null +++ b/assets/scss/hyde-hyde/_variables.scss @@ -0,0 +1,119 @@ +$gray-0: #fafafa; +$gray-1: #f9f9f9; +$gray-2: #eee; +$gray-3: #ddd; +$gray-4: #ccc; +$gray-5: #bbb; +$gray-6: #878787; +$gray-7: #767676; +$gray-8: #515151; +$gray-9: #313131; + +$white: #fff; +$red: #ac4142; +$orange: #d28445; +$yellow: #f4bf75; +$green: #90a959; +$cyan: #75b5aa; +$blue: #268bd2; +$brown: #8f5536; + +//https://www.client9.com/css-system-font-stack-sans-serif-v3 +$root-font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Droid Sans", "Ubuntu", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol"; + +// poole's variables +$root-font-size: 17px; +$root-font-weight: 400; +// golden ratio https://grtcalculator.com +// 18px @ 33 px, 20px @ 33 px ~ 1.667em +$root-line-height: 1.667em; + +$body-color: $gray-8; +$body-bg: #fff; + +$border-color: #e5e5e5; + +$large-breakpoint: 38em; +$large-font-size: 19px; +$font-scale-dot7: .7rem; +$font-scale-dot8: .8rem; +// + +// hyde-hyde +$small-device-font-size: $root-font-size; +$large-device-font-size: $large-font-size; + +// https://www.client9.com/css-system-font-stack-monospace-v2 +$code-font-family: "SFMono-Regular", "SF-Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Roboto Mono", "Ubuntu Mono", "Courier New", Courier, monospace; +$code-font-size: .9rem; +$code-fence-font-size: .8rem; +//$code-color: #bf616a; +//$code-background-color: #f9f2f4; +$code-line-height: 1.4; + +// links +$link-color: $blue; +$link-hover-color: $body-color; + +// section +$section__title-font-size: 2.15rem; + +// post +$post__subtitle-font-size: 1.5rem; +$gradient-color-1: #ff2c2c; +$gradient-color-2: #7a5e91; + +// post meta +$meta-font-size: $font-scale-dot8; +$meta-font-weight: 300; +$meta-color: $gray-6; + +// post tags +$tag-background-color: $gray-2; +$tag-color: #606570; +$tag-font-size: .667rem; + +// list of posts +$item__date-color: #9a9a9a; +$item__date-font-size: 1rem; +$item__title-big-font-size: 1.785rem; + +// heading +$heading-font-weight: 400; +$h1-font-size: 2.15rem; +$h1-line-height: 1.25; +$h2-font-size: 1.85rem; +$h3-font-size: 1.5rem; +$h4-font-size:1.3rem; +$h5-font-size:1rem; + + +// sidebar +$sidebar-color: #300030; +$sidebar-width: 16rem; +$site__title-font-size: 2.5rem; +$copyright-font-size: $font-scale-dot7; + +// content +$content-max-width: 100%; // @ ~70 CPL +$content-margin-left: $sidebar-width + 2rem; +$content-margin-right: 2rem; + +// navigation +$navigation-color: #c2255c; + +// portfolio +$project__title-font-size: $h2-font-size; +$project__subtitle-font-size-big: $h3-font-size; +$project__subtitle-font-size-small: $h4-font-size; +$project__subtitle-font-style: italic; +$project__subtitle-color: #778492; +$ribbon-color: #276582; +$ribbon-background-color: #479fc8; + +// blog +$blog__title-font-size: $project__title-font-size; +$blog__subtitle-font-size-big: $project__subtitle-font-size-big; +$blog__subtitle-font-size-small: $project__subtitle-font-size-small; +$blog__subtitle-font-style: $project__subtitle-font-style; +$blog__subtitle-color: $project__subtitle-color; diff --git a/assets/scss/poole/_base.scss b/assets/scss/poole/_base.scss new file mode 100644 index 0000000..724067a --- /dev/null +++ b/assets/scss/poole/_base.scss @@ -0,0 +1,78 @@ +// Body resets +// +// Update the foundational and global aspects of the page. + +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +html, +body { + margin: 0; + padding: 0; +} + +html { + font-family: $root-font-family; + font-size: $root-font-size; + line-height: $root-line-height; + + @media (min-width: $large-breakpoint) { + font-size: $large-font-size; + } +} + +body { + color: $body-color; + background-color: $body-bg; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +// No `:visited` state is required by default (browsers will use `a`) +a { + color: $link-color; + text-decoration: none; + + // `:focus` is linked to `:hover` for basic accessibility + &:hover, + &:focus { + text-decoration: underline; + } + + strong { + color: inherit; + } +} + +img { + display: block; + max-width: 100%; + margin: 0 0 1rem; + border-radius: 5px; +} + +table { + margin-bottom: 1rem; + width: 100%; + font-size: 85%; + border: 1px solid #e5e5e5; + border-collapse: collapse; +} + +td, +th { + padding: .25rem .5rem; + border: 1px solid #e5e5e5; +} + +th { + text-align: left; +} + +tbody tr:nth-child(odd) td, +tbody tr:nth-child(odd) th { + background-color: #f9f9f9; +} diff --git a/assets/scss/poole/_code.scss b/assets/scss/poole/_code.scss new file mode 100644 index 0000000..775cc52 --- /dev/null +++ b/assets/scss/poole/_code.scss @@ -0,0 +1,78 @@ +// Code +// +// Inline and block-level code snippets. Includes tweaks to syntax highlighted +// snippets from Pygments/Rouge and Gist embeds. + +code, +pre { + font-family: $code-font-family; +} + +code { + padding: .25em .5em; + font-size: 85%; + color: $code-color; + background-color: #f9f9f9; + border-radius: 3px; +} + +pre { + margin-top: 0; + margin-bottom: 1rem; +} + +pre code { + padding: 0; + font-size: 100%; + color: inherit; + background-color: transparent; +} + +// Pygments via Jekyll +.highlight { + padding: 1rem; + margin-bottom: 1rem; + font-size: .8rem; + line-height: 1.4; + background-color: #f9f9f9; + border-radius: .25rem; + + pre { + margin-bottom: 0; + overflow-x: auto; + } + + .lineno { + display: inline-block; // Ensures the null space also isn't selectable + padding-right: .75rem; + padding-left: .25rem; + color: #999; + // Make sure numbers aren't selectable + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + } +} + + +// Gist via GitHub Pages +// .gist .gist-file { +// font-family: Menlo, Monaco, "Courier New", monospace !important; +// } +// .gist .markdown-body { +// padding: 15px; +// } +// .gist pre { +// padding: 0; +// background-color: transparent; +// } +// .gist .gist-file .gist-data { +// font-size: .8rem !important; +// line-height: 1.4; +// } +// .gist code { +// padding: 0; +// color: inherit; +// background-color: transparent; +// border-radius: 0; +// } diff --git a/assets/scss/poole/_layout.scss b/assets/scss/poole/_layout.scss new file mode 100644 index 0000000..2a27269 --- /dev/null +++ b/assets/scss/poole/_layout.scss @@ -0,0 +1,15 @@ +// Layout +// +// Styles for managing the structural hierarchy of the site. + +.container { + max-width: 38rem; + padding-left: 1.5rem; + padding-right: 1.5rem; + margin-left: auto; + margin-right: auto; +} + +footer { + margin-bottom: 2rem; +} diff --git a/assets/scss/poole/_masthead.scss b/assets/scss/poole/_masthead.scss new file mode 100644 index 0000000..29d406e --- /dev/null +++ b/assets/scss/poole/_masthead.scss @@ -0,0 +1,25 @@ +// Masthead +// +// Super small header above the content for site name and short description. + +.masthead { + padding-top: 1rem; + padding-bottom: 1rem; + margin-bottom: 3rem; +} + +.masthead-title { + margin-top: 0; + margin-bottom: 0; + color: $gray-4; + + a { + color: inherit; + } + + small { + font-size: 75%; + font-weight: 400; + opacity: .5; + } +} diff --git a/assets/scss/poole/_message.scss b/assets/scss/poole/_message.scss new file mode 100644 index 0000000..42bf2e5 --- /dev/null +++ b/assets/scss/poole/_message.scss @@ -0,0 +1,11 @@ +// Messages +// +// Show alert messages to users. You may add it to single elements like a `

`, +// or to a parent if there are multiple elements to show. + +.message { + margin-bottom: 1rem; + padding: 1rem; + color: #717171; + background-color: #f9f9f9; +} diff --git a/assets/scss/poole/_pagination.scss b/assets/scss/poole/_pagination.scss new file mode 100644 index 0000000..5ef8f90 --- /dev/null +++ b/assets/scss/poole/_pagination.scss @@ -0,0 +1,51 @@ +// Pagination +// +// Super lightweight (HTML-wise) blog pagination. `span`s are provide for when +// there are no more previous or next posts to show. + +.pagination { + overflow: hidden; // clearfix + margin: 0 -1.5rem 1rem; + color: #ccc; + text-align: center; +} + +// Pagination items can be `span`s or `a`s +.pagination-item { + display: block; + padding: 1rem; + border: solid #eee; + border-width: 1px 0; + + &:first-child { + margin-bottom: -1px; + } +} + +// Only provide a hover state for linked pagination items +a.pagination-item:hover { + background-color: #f5f5f5; +} + +@media (min-width: 30em) { + .pagination { + margin: 3rem 0; + } + + .pagination-item { + float: left; + width: 50%; + border-width: 1px; + + &:first-child { + margin-bottom: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + } + &:last-child { + margin-left: -1px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + } + } +} diff --git a/assets/scss/poole/_poole.scss b/assets/scss/poole/_poole.scss new file mode 100644 index 0000000..da6a97f --- /dev/null +++ b/assets/scss/poole/_poole.scss @@ -0,0 +1,23 @@ +// +// ___ +// /\_ \ +// _____ ___ ___\//\ \ __ +// /\ '__`\ / __`\ / __`\\ \ \ /'__`\ +// \ \ \_\ \/\ \_\ \/\ \_\ \\_\ \_/\ __/ +// \ \ ,__/\ \____/\ \____//\____\ \____\ +// \ \ \/ \/___/ \/___/ \/____/\/____/ +// \ \_\ +// \/_/ +// +// Designed, built, and released under MIT license by @mdo. Learn more at +// https://github.com/poole/poole. +@import "variables"; +@import "base"; +@import "type"; +@import "syntax"; +@import "code"; +@import "layout"; +@import "masthead"; +@import "posts"; +@import "pagination"; +@import "message"; diff --git a/assets/scss/poole/_posts.scss b/assets/scss/poole/_posts.scss new file mode 100644 index 0000000..c6af601 --- /dev/null +++ b/assets/scss/poole/_posts.scss @@ -0,0 +1,67 @@ +// Posts and pages +// +// Each post is wrapped in `.post` and is used on default and post layouts. Each +// page is wrapped in `.page` and is only used on the page layout. + +.page, +.post { + margin-bottom: 4em; + + li + li { + margin-top: .25rem; + } +} + +// Blog post or page title +.page-title, +.post-title, +.post-title a { + color: #303030; +} +.page-title, +.post-title { + margin-top: 0; +} + +// Meta data line below post title +.post-date { + display: block; + margin-top: -.5rem; + margin-bottom: 1rem; + color: #9a9a9a; +} + + +// Related posts +.related { + padding-top: 2rem; + padding-bottom: 2rem; + margin-bottom: 2rem; + border-top: 1px solid #eee; + border-bottom: 1px solid #eee; +} + +.related-posts { + padding-left: 0; + list-style: none; + + h3 { + margin-top: 0; + } + + li { + small { + font-size: 75%; + color: #999; + } + + a:hover { + color: #268bd2; + text-decoration: none; + + small { + color: inherit; + } + } + } +} diff --git a/assets/scss/poole/_syntax.scss b/assets/scss/poole/_syntax.scss new file mode 100644 index 0000000..15ad797 --- /dev/null +++ b/assets/scss/poole/_syntax.scss @@ -0,0 +1,65 @@ +.highlight .hll { background-color: #ffc; } +.highlight .c { color: #999; } /* Comment */ +.highlight .err { color: #a00; background-color: #faa } /* Error */ +.highlight .k { color: #069; } /* Keyword */ +.highlight .o { color: #555 } /* Operator */ +.highlight .cm { color: #09f; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #099 } /* Comment.Preproc */ +.highlight .c1 { color: #999; } /* Comment.Single */ +.highlight .cs { color: #999; } /* Comment.Special */ +.highlight .gd { background-color: #fcc; border: 1px solid #c00 } /* Generic.Deleted */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #f00 } /* Generic.Error */ +.highlight .gh { color: #030; } /* Generic.Heading */ +.highlight .gi { background-color: #cfc; border: 1px solid #0c0 } /* Generic.Inserted */ +.highlight .go { color: #aaa } /* Generic.Output */ +.highlight .gp { color: #009; } /* Generic.Prompt */ +.highlight .gs { } /* Generic.Strong */ +.highlight .gu { color: #030; } /* Generic.Subheading */ +.highlight .gt { color: #9c6 } /* Generic.Traceback */ +.highlight .kc { color: #069; } /* Keyword.Constant */ +.highlight .kd { color: #069; } /* Keyword.Declaration */ +.highlight .kn { color: #069; } /* Keyword.Namespace */ +.highlight .kp { color: #069 } /* Keyword.Pseudo */ +.highlight .kr { color: #069; } /* Keyword.Reserved */ +.highlight .kt { color: #078; } /* Keyword.Type */ +.highlight .m { color: #f60 } /* Literal.Number */ +.highlight .s { color: #d44950 } /* Literal.String */ +.highlight .na { color: #4f9fcf } /* Name.Attribute */ +.highlight .nb { color: #366 } /* Name.Builtin */ +.highlight .nc { color: #0a8; } /* Name.Class */ +.highlight .no { color: #360 } /* Name.Constant */ +.highlight .nd { color: #99f } /* Name.Decorator */ +.highlight .ni { color: #999; } /* Name.Entity */ +.highlight .ne { color: #c00; } /* Name.Exception */ +.highlight .nf { color: #c0f } /* Name.Function */ +.highlight .nl { color: #99f } /* Name.Label */ +.highlight .nn { color: #0cf; } /* Name.Namespace */ +.highlight .nt { color: #2f6f9f; } /* Name.Tag */ +.highlight .nv { color: #033 } /* Name.Variable */ +.highlight .ow { color: #000; } /* Operator.Word */ +.highlight .w { color: #bbb } /* Text.Whitespace */ +.highlight .mf { color: #f60 } /* Literal.Number.Float */ +.highlight .mh { color: #f60 } /* Literal.Number.Hex */ +.highlight .mi { color: #f60 } /* Literal.Number.Integer */ +.highlight .mo { color: #f60 } /* Literal.Number.Oct */ +.highlight .sb { color: #c30 } /* Literal.String.Backtick */ +.highlight .sc { color: #c30 } /* Literal.String.Char */ +.highlight .sd { color: #c30; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #c30 } /* Literal.String.Double */ +.highlight .se { color: #c30; } /* Literal.String.Escape */ +.highlight .sh { color: #c30 } /* Literal.String.Heredoc */ +.highlight .si { color: #a00 } /* Literal.String.Interpol */ +.highlight .sx { color: #c30 } /* Literal.String.Other */ +.highlight .sr { color: #3aa } /* Literal.String.Regex */ +.highlight .s1 { color: #c30 } /* Literal.String.Single */ +.highlight .ss { color: #fc3 } /* Literal.String.Symbol */ +.highlight .bp { color: #366 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #033 } /* Name.Variable.Class */ +.highlight .vg { color: #033 } /* Name.Variable.Global */ +.highlight .vi { color: #033 } /* Name.Variable.Instance */ +.highlight .il { color: #f60 } /* Literal.Number.Integer.Long */ + +.css .o, +.css .o + .nt, +.css .nt + .nt { color: #999; } diff --git a/assets/scss/poole/_type.scss b/assets/scss/poole/_type.scss new file mode 100644 index 0000000..504e57b --- /dev/null +++ b/assets/scss/poole/_type.scss @@ -0,0 +1,117 @@ +// Typography +// +// Headings, body text, lists, and other misc typographic elements. + +h1, h2, h3, h4, h5, h6 { + margin-bottom: .5rem; + font-weight: 600; + line-height: 1.25; + color: #313131; + text-rendering: optimizeLegibility; +} + +h1 { + font-size: 2rem; +} + +h2 { + margin-top: 1rem; + font-size: 1.5rem; +} + +h3 { + margin-top: 1.5rem; + font-size: 1.25rem; +} + +h4, h5, h6 { + margin-top: 1rem; + font-size: 1rem; +} + +p { + margin-top: 0; + margin-bottom: 1rem; +} + +strong { + color: #303030; +} + +ul, ol, dl { + margin-top: 0; + margin-bottom: 1rem; +} + +dt { + font-weight: bold; +} + +dd { + margin-bottom: .5rem; +} + +hr { + position: relative; + margin: 1.5rem 0; + border: 0; + border-top: 1px solid #eee; + border-bottom: 1px solid #fff; +} + +abbr { + font-size: 85%; + font-weight: bold; + color: #555; + text-transform: uppercase; + + &[title] { + cursor: help; + border-bottom: 1px dotted #e5e5e5; + } +} + +blockquote { + padding: .5rem 1rem; + margin: .8rem 0; + color: #7a7a7a; + border-left: .25rem solid #e5e5e5; + + p:last-child { + margin-bottom: 0; + } + + @media (min-width: 30em) { + padding-right: 5rem; + padding-left: 1.25rem; + } +} + + +// Markdown footnotes +// +// See the example content post for an example. + +// Footnote number within body text +a[href^="#fn:"], +// Back to footnote link +a[href^="#fnref:"] { + display: inline-block; + margin-left: .1rem; + font-weight: bold; +} + +// List of footnotes +.footnotes { + margin-top: 2rem; + font-size: 85%; +} + +// Custom type +// +// Extend paragraphs with `.lead` for larger introductory text. + +.lead { + font-size: 1.25rem; + font-weight: 300; +} diff --git a/assets/scss/poole/_variables.scss b/assets/scss/poole/_variables.scss new file mode 100644 index 0000000..3e0aa40 --- /dev/null +++ b/assets/scss/poole/_variables.scss @@ -0,0 +1,30 @@ +$gray-1: #f9f9f9; +$gray-2: #ccc; +$gray-3: #767676; +$gray-4: #515151; +$gray-5: #313131; + +$red: #ac4142; +$orange: #d28445; +$yellow: #f4bf75; +$green: #90a959; +$cyan: #75b5aa; +$blue: #268bd2; +// $blue: #6a9fb5; +$brown: #8f5536; + +$root-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; +$root-font-size: 16px; +$root-line-height: 1.5; + +$body-color: #515151; +$body-bg: #fff; +$link-color: $blue; + +$border-color: #e5e5e5; + +$large-breakpoint: 38em; +$large-font-size: 20px; + +$code-font-family: Menlo, Monaco, "Courier New", monospace; +$code-color: #bf616a; diff --git a/assets/scss/print.scss b/assets/scss/print.scss new file mode 100644 index 0000000..e3bbd0c --- /dev/null +++ b/assets/scss/print.scss @@ -0,0 +1,2 @@ +@import "hyde-hyde/variables"; +@import 'hyde-hyde/print'; diff --git a/assets/scss/tocbot.scss b/assets/scss/tocbot.scss new file mode 100644 index 0000000..ae50082 --- /dev/null +++ b/assets/scss/tocbot.scss @@ -0,0 +1,31 @@ +@import 'hugo-toc'; + +.toc { + font-size: $toc-font-size; + overflow-y: auto; + background: $toc-background-color; + padding-left: 0rem; + padding-top: 1em; + > .toc-list { + overflow: hidden; + position: relative; + li { + list-style: none; + } + } +} +.toc-list { + margin: 0; + padding-left: 1rem; +} +.is-collapsible { + max-height: 1000px; + overflow: hidden; +} +.is-collapsed { + max-height: 0; +} +.is-position-fixed { + position: fixed; + top: 0; +} diff --git a/exampleSite/.gitignore b/exampleSite/.gitignore new file mode 100644 index 0000000..7da2186 --- /dev/null +++ b/exampleSite/.gitignore @@ -0,0 +1,3 @@ +/public +/themes +.DS_Store diff --git a/exampleSite/config.toml b/exampleSite/config.toml new file mode 100644 index 0000000..7e3baed --- /dev/null +++ b/exampleSite/config.toml @@ -0,0 +1,77 @@ +## Basic Configuration +baseurl = "https://example.com/" +languageCode = "en" + +title = "Title" +theme = "hyde-hyde" + +## Hugo Built-in Features +# disqusShortname = "your-disqus-shortname" +# googleAnalytics = "your-google-analytics-id" +# enableRobotsTXT = true + +# summarylength = 30 + +#paginate = 5 + +## Site Settings +[params] + author = "Author" + title = "Title" + # description = "..." + authorimage = "/img/hugo.png" + dateformat = "Jan 2, 2006" + + # sidebar, copyright & license + #logoimage = "/img/hugo.png" + copyright = "htr3n" + since = 2019 + license = "CC BY-SA 4.0" + licenseURL = "https://creativecommons.org/licenses/by-sa/4.0" + showBuiltWith = true + + # https://highlightjs.org + highlightjs = true + highlightjsstyle = "github" + + # please choose either GraphComment or Disqus or Utterances + #GraphCommentId = "..." + #UtterancesRepo = "..." # https://utteranc.es/ + #UtterancesIssueTerm = "..." # pathname, url, title, og:title + #UtterancesTheme = "..." # github-light or github-dark + + # Table of contents + #toc = none, "hugo", or "tocbot" + +## Social Accounts +[params.social] + github = "" + instagram = "" + xing = "" + linkedin = "" + twitter = "" + facebook = "" + microblog = "" + stackoverflow = "" + telegram = "" + # orcid = "" + email = "your-email@example.com" + # gravatar = "your-email@example.com" + # pgpkey = "" + +## Main Menu +[[menu.main]] + name = "Posts" + weight = 100 + identifier = "posts" + url = "/posts/" +[[menu.main]] + name = "Portfolio" + identifier = "portfolio" + weight = 200 + url = "/portfolio/" +[[menu.main]] + name = "About" + identifier = "about" + weight = 300 + url = "/about/" diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md new file mode 100644 index 0000000..dcdba32 --- /dev/null +++ b/exampleSite/content/about.md @@ -0,0 +1,17 @@ ++++ +title = "About Hugo" +date = "2014-04-09" ++++ + +Hugo is a static site engine written in Go. + + +It makes use of a variety of open source projects including: + +* [Cobra](https://github.com/spf13/cobra) +* [Viper](https://github.com/spf13/viper) +* [J Walter Weatherman](https://github.com/spf13/jWalterWeatherman) +* [Cast](https://github.com/spf13/cast) + +Learn more and contribute on [GitHub](https://github.com/gohugoio). + diff --git a/exampleSite/content/portfolio/_index.md b/exampleSite/content/portfolio/_index.md new file mode 100644 index 0000000..716316c --- /dev/null +++ b/exampleSite/content/portfolio/_index.md @@ -0,0 +1,3 @@ +--- +title: 'Projects' +--- diff --git a/exampleSite/content/portfolio/dera.md b/exampleSite/content/portfolio/dera.md new file mode 100644 index 0000000..3314f1e --- /dev/null +++ b/exampleSite/content/portfolio/dera.md @@ -0,0 +1,10 @@ +--- +title: "DERA" +description: "Dynamic Event-Driven Actors" +link: https://github.com/htr3n/dera +screenshot: dera.png +date: '2018-06-21' +layout: 'portfolio' +--- + +This is a Java reference implementation of dynamic event-driven actors runtime aiming at providing adequate abstraction levels and mechanisms for modelling and developing (distributed) event-based systems. DERA leverages the intrinsic loose coupling of event-driven communication styles to support various kinds of _run-time evolution and adaptation_ (i.e., enabling run-time flexibility) while _minimizing the non-deterministic nature of traditional event-based applications_ (i.e., supporting formal analysis). \ No newline at end of file diff --git a/exampleSite/content/portfolio/dera.png b/exampleSite/content/portfolio/dera.png new file mode 100644 index 0000000..aa0ccd8 Binary files /dev/null and b/exampleSite/content/portfolio/dera.png differ diff --git a/exampleSite/content/portfolio/hyde-hyde.md b/exampleSite/content/portfolio/hyde-hyde.md new file mode 100644 index 0000000..e3b9936 --- /dev/null +++ b/exampleSite/content/portfolio/hyde-hyde.md @@ -0,0 +1,11 @@ +--- +title: "hyde-hyde" +description: "A simple and cool Hugo theme" +date: '2018-01-27' +link: 'https://github.com/htr3n/hyde-hyde' +screenshot: 'hyde-hyde.png' +layout: 'portfolio' +featured: 'true' +--- + +[_Hyde-hyde_](https://github.com/htr3n/hyde-hyde) is a responsive [Hugo](https://gohugo.io) theme inspired by @spf13's [Hyde](https://github.com/spf13/hyde.git) and its variant [Nate Finch's blog](https://npf.io). It was heavily restructured with modularised page layouts for easier maintenance and modification. _Hyde-hyde_ offers awesome features such as nice colour tone, [code highlighting](https://highlightjs.org), [Font-Awesome 5's sidebar icons](https://fontawesome.com)), a cool portfolio page, more choices for commenting (e.g. [GraphComment](https://graphcomment.com), [Disqus](https://disqus.com)). diff --git a/exampleSite/content/portfolio/hyde-hyde.png b/exampleSite/content/portfolio/hyde-hyde.png new file mode 100644 index 0000000..c90b6f7 Binary files /dev/null and b/exampleSite/content/portfolio/hyde-hyde.png differ diff --git a/exampleSite/content/portfolio/laramod.md b/exampleSite/content/portfolio/laramod.md new file mode 100644 index 0000000..328c9eb --- /dev/null +++ b/exampleSite/content/portfolio/laramod.md @@ -0,0 +1,10 @@ +--- +title: "LaraMod" +description: "A modularised Laravel framework" +link: https://github.com/htr3n/laramod +screenshot: laramod.png +date: '2018-01-19' +layout: portfolio +--- + +[LaraMod](https://github.com/htr3n/laramod) is another modularisation effort to systematically organising a [Laravel](https://laravel.com) based project. The idea stems from my struggle to structure a Laravel-based project so that I can work effectively on individual modules whilst keeping Laravel codebase intact as much as possible and also keeping the project's codebase separate from Laravel. \ No newline at end of file diff --git a/exampleSite/content/portfolio/laramod.png b/exampleSite/content/portfolio/laramod.png new file mode 100644 index 0000000..cac4851 Binary files /dev/null and b/exampleSite/content/portfolio/laramod.png differ diff --git a/exampleSite/content/posts/creating-a-new-theme.md b/exampleSite/content/posts/creating-a-new-theme.md new file mode 100644 index 0000000..d9023b0 --- /dev/null +++ b/exampleSite/content/posts/creating-a-new-theme.md @@ -0,0 +1,1147 @@ +--- +author: "Michael Henderson" +date: 2014-09-28 +linktitle: Creating a New Theme +title: Creating a New Theme +categories: [ "Development", "hugo" ] +tags: ["hugo", "theme", "html", "css"] +weight: 10 +--- + + +## Introduction + +This tutorial will show you how to create a simple theme in Hugo. I assume that you are familiar with HTML, the bash command line, and that you are comfortable using Markdown to format content. I'll explain how Hugo uses templates and how you can organize your templates to create a theme. I won't cover using CSS to style your theme. + +We'll start with creating a new site with a very basic template. Then we'll add in a few pages and posts. With small variations on that, you will be able to create many different types of web sites. + +In this tutorial, commands that you enter will start with the "$" prompt. The output will follow. Lines that start with "#" are comments that I've added to explain a point. When I show updates to a file, the ":wq" on the last line means to save the file. + +Here's an example: + +``` +## this is a comment +$ echo this is a command +this is a command + +## edit the file +$vi foo.md ++++ +date = "2014-09-28" +title = "creating a new theme" ++++ + +bah and humbug +:wq + +## show it +$ cat foo.md ++++ +date = "2014-09-28" +title = "creating a new theme" ++++ + +bah and humbug +$ +``` + + +## Some Definitions + +There are a few concepts that you need to understand before creating a theme. + +### Skins + +Skins are the files responsible for the look and feel of your site. It’s the CSS that controls colors and fonts, it’s the Javascript that determines actions and reactions. It’s also the rules that Hugo uses to transform your content into the HTML that the site will serve to visitors. + +You have two ways to create a skin. The simplest way is to create it in the ```layouts/``` directory. If you do, then you don’t have to worry about configuring Hugo to recognize it. The first place that Hugo will look for rules and files is in the ```layouts/``` directory so it will always find the skin. + +Your second choice is to create it in a sub-directory of the ```themes/``` directory. If you do, then you must always tell Hugo where to search for the skin. It’s extra work, though, so why bother with it? + +The difference between creating a skin in ```layouts/``` and creating it in ```themes/``` is very subtle. A skin in ```layouts/``` can’t be customized without updating the templates and static files that it is built from. A skin created in ```themes/```, on the other hand, can be and that makes it easier for other people to use it. + +The rest of this tutorial will call a skin created in the ```themes/``` directory a theme. + +Note that you can use this tutorial to create a skin in the ```layouts/``` directory if you wish to. The main difference will be that you won’t need to update the site’s configuration file to use a theme. + +### The Home Page + +The home page, or landing page, is the first page that many visitors to a site see. It is the index.html file in the root directory of the web site. Since Hugo writes files to the public/ directory, our home page is public/index.html. + +### Site Configuration File + +When Hugo runs, it looks for a configuration file that contains settings that override default values for the entire site. The file can use TOML, YAML, or JSON. I prefer to use TOML for my configuration files. If you prefer to use JSON or YAML, you’ll need to translate my examples. You’ll also need to change the name of the file since Hugo uses the extension to determine how to process it. + +Hugo translates Markdown files into HTML. By default, Hugo expects to find Markdown files in your ```content/``` directory and template files in your ```themes/``` directory. It will create HTML files in your ```public/``` directory. You can change this by specifying alternate locations in the configuration file. + +### Content + +Content is stored in text files that contain two sections. The first section is the “front matter,” which is the meta-information on the content. The second section contains Markdown that will be converted to HTML. + +#### Front Matter + +The front matter is information about the content. Like the configuration file, it can be written in TOML, YAML, or JSON. Unlike the configuration file, Hugo doesn’t use the file’s extension to know the format. It looks for markers to signal the type. TOML is surrounded by “`+++`”, YAML by “`---`”, and JSON is enclosed in curly braces. I prefer to use TOML, so you’ll need to translate my examples if you prefer YAML or JSON. + +The information in the front matter is passed into the template before the content is rendered into HTML. + +#### Markdown + +Content is written in Markdown which makes it easier to create the content. Hugo runs the content through a Markdown engine to create the HTML which will be written to the output file. + +### Template Files + +Hugo uses template files to render content into HTML. Template files are a bridge between the content and presentation. Rules in the template define what content is published, where it's published to, and how it will rendered to the HTML file. The template guides the presentation by specifying the style to use. + +There are three types of templates: single, list, and partial. Each type takes a bit of content as input and transforms it based on the commands in the template. + +Hugo uses its knowledge of the content to find the template file used to render the content. If it can’t find a template that is an exact match for the content, it will shift up a level and search from there. It will continue to do so until it finds a matching template or runs out of templates to try. If it can’t find a template, it will use the default template for the site. + +Please note that you can use the front matter to influence Hugo’s choice of templates. + +#### Single Template + +A single template is used to render a single piece of content. For example, an article or post would be a single piece of content and use a single template. + +#### List Template + +A list template renders a group of related content. That could be a summary of recent postings or all articles in a category. List templates can contain multiple groups. + +The homepage template is a special type of list template. Hugo assumes that the home page of your site will act as the portal for the rest of the content in the site. + +#### Partial Template + +A partial template is a template that can be included in other templates. Partial templates must be called using the “partial” template command. They are very handy for rolling up common behavior. For example, your site may have a banner that all pages use. Instead of copying the text of the banner into every single and list template, you could create a partial with the banner in it. That way if you decide to change the banner, you only have to change the partial template. + +## Create a New Site + +Let's use Hugo to create a new web site. I'm a Mac user, so I'll create mine in my home directory, in the Sites folder. If you're using Linux, you might have to create the folder first. + +The "new site" command will create a skeleton of a site. It will give you the basic directory structure and a useable configuration file. + +``` +$ hugo new site ~/Sites/zafta +$ cd ~/Sites/zafta +$ ls -l +total 8 +drwxr-xr-x 7 quoha staff 238 Sep 29 16:49 . +drwxr-xr-x 3 quoha staff 102 Sep 29 16:49 .. +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +$ +``` + +Take a look in the content/ directory to confirm that it is empty. + +The other directories (archetypes/, layouts/, and static/) are used when customizing a theme. That's a topic for a different tutorial, so please ignore them for now. + +### Generate the HTML For the New Site + +Running the `hugo` command with no options will read all the available content and generate the HTML files. It will also copy all static files (that's everything that's not content). Since we have an empty site, it won't do much, but it will do it very quickly. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +$ +``` + +The "`--verbose`" flag gives extra information that will be helpful when we build the template. Every line of the output that starts with "INFO:" or "WARN:" is present because we used that flag. The lines that start with "WARN:" are warning messages. We'll go over them later. + +We can verify that the command worked by looking at the directory again. + +``` +$ ls -l +total 8 +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:02 public +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +$ +``` + +See that new public/ directory? Hugo placed all generated content there. When you're ready to publish your web site, that's the place to start. For now, though, let's just confirm that we have what we'd expect from a site with no content. + +``` +$ ls -l public +total 16 +-rw-r--r-- 1 quoha staff 416 Sep 29 17:02 index.xml +-rw-r--r-- 1 quoha staff 262 Sep 29 17:02 sitemap.xml +$ +``` + +Hugo created two XML files, which is standard, but there are no HTML files. + + + +### Test the New Site + +Verify that you can run the built-in web server. It will dramatically shorten your development cycle if you do. Start it by running the "server" command. If it is successful, you will see output similar to the following: + +``` +$ hugo server --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +Serving pages from /Users/quoha/Sites/zafta/public +Web Server is available at http://localhost:1313 +Press Ctrl+C to stop +``` + +Connect to the listed URL (it's on the line that starts with "Web Server"). If everything is working correctly, you should get a page that shows the following: + +``` +index.xml +sitemap.xml +``` + +That's a listing of your public/ directory. Hugo didn't create a home page because our site has no content. When there's no index.html file in a directory, the server lists the files in the directory, which is what you should see in your browser. + +Let’s go back and look at those warnings again. + +``` +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +``` + +That second warning is easier to explain. We haven’t created a template to be used to generate “page not found errors.” The 404 message is a topic for a separate tutorial. + +Now for the first warning. It is for the home page. You can tell because the first layout that it looked for was “index.html.” That’s only used by the home page. + +I like that the verbose flag causes Hugo to list the files that it's searching for. For the home page, they are index.html, _default/list.html, and _default/single.html. There are some rules that we'll cover later that explain the names and paths. For now, just remember that Hugo couldn't find a template for the home page and it told you so. + +At this point, you've got a working installation and site that we can build upon. All that’s left is to add some content and a theme to display it. + +## Create a New Theme + +Hugo doesn't ship with a default theme. There are a few available (I counted a dozen when I first installed Hugo) and Hugo comes with a command to create new themes. + +We're going to create a new theme called "zafta." Since the goal of this tutorial is to show you how to fill out the files to pull in your content, the theme will not contain any CSS. In other words, ugly but functional. + +All themes have opinions on content and layout. For example, Zafta uses "post" over "blog". Strong opinions make for simpler templates but differing opinions make it tougher to use themes. When you build a theme, consider using the terms that other themes do. + + +### Create a Skeleton + +Use the hugo "new" command to create the skeleton of a theme. This creates the directory structure and places empty files for you to fill out. + +``` +$ hugo new theme zafta + +$ ls -l +total 8 +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:02 public +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +drwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes + +$ find themes -type f | xargs ls -l +-rw-r--r-- 1 quoha staff 1081 Sep 29 17:31 themes/zafta/LICENSE.md +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/archetypes/default.md +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html +-rw-r--r-- 1 quoha staff 93 Sep 29 17:31 themes/zafta/theme.toml +$ +``` + +The skeleton includes templates (the files ending in .html), license file, a description of your theme (the theme.toml file), and an empty archetype. + +Please take a minute to fill out the theme.toml and LICENSE.md files. They're optional, but if you're going to be distributing your theme, it tells the world who to praise (or blame). It's also nice to declare the license so that people will know how they can use the theme. + +``` +$ vi themes/zafta/theme.toml +author = "michael d henderson" +description = "a minimal working template" +license = "MIT" +name = "zafta" +source_repo = "" +tags = ["tags", "categories"] +:wq + +## also edit themes/zafta/LICENSE.md and change +## the bit that says "YOUR_NAME_HERE" +``` + +Note that the the skeleton's template files are empty. Don't worry, we'll be changing that shortly. + +``` +$ find themes/zafta -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html +$ +``` + + + +### Update the Configuration File to Use the Theme + +Now that we've got a theme to work with, it's a good idea to add the theme name to the configuration file. This is optional, because you can always add "-t zafta" on all your commands. I like to put it the configuration file because I like shorter command lines. If you don't put it in the configuration file or specify it on the command line, you won't use the template that you're expecting to. + +Edit the file to add the theme, add a title for the site, and specify that all of our content will use the TOML format. + +``` +$ vi config.toml +theme = "zafta" +baseurl = "" +languageCode = "en-us" +title = "zafta - totally refreshing" +MetaDataFormat = "toml" +:wq + +$ +``` + +### Generate the Site + +Now that we have an empty theme, let's generate the site again. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +$ +``` + +Did you notice that the output is different? The warning message for the home page has disappeared and we have an additional information line saying that Hugo is syncing from the theme's directory. + +Let's check the public/ directory to see what Hugo's created. + +``` +$ ls -l public +total 16 +drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 css +-rw-r--r-- 1 quoha staff 0 Sep 29 17:56 index.html +-rw-r--r-- 1 quoha staff 407 Sep 29 17:56 index.xml +drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 js +-rw-r--r-- 1 quoha staff 243 Sep 29 17:56 sitemap.xml +$ +``` + +Notice four things: + +1. Hugo created a home page. This is the file public/index.html. +2. Hugo created a css/ directory. +3. Hugo created a js/ directory. +4. Hugo claimed that it created 0 pages. It created a file and copied over static files, but didn't create any pages. That's because it considers a "page" to be a file created directly from a content file. It doesn't count things like the index.html files that it creates automatically. + +#### The Home Page + +Hugo supports many different types of templates. The home page is special because it gets its own type of template and its own template file. The file, layouts/index.html, is used to generate the HTML for the home page. The Hugo documentation says that this is the only required template, but that depends. Hugo's warning message shows that it looks for three different templates: + +``` +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +``` + +If it can't find any of these, it completely skips creating the home page. We noticed that when we built the site without having a theme installed. + +When Hugo created our theme, it created an empty home page template. Now, when we build the site, Hugo finds the template and uses it to generate the HTML for the home page. Since the template file is empty, the HTML file is empty, too. If the template had any rules in it, then Hugo would have used them to generate the home page. + +``` +$ find . -name index.html | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 20:21 ./public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 ./themes/zafta/layouts/index.html +$ +``` + +#### The Magic of Static + +Hugo does two things when generating the site. It uses templates to transform content into HTML and it copies static files into the site. Unlike content, static files are not transformed. They are copied exactly as they are. + +Hugo assumes that your site will use both CSS and JavaScript, so it creates directories in your theme to hold them. Remember opinions? Well, Hugo's opinion is that you'll store your CSS in a directory named css/ and your JavaScript in a directory named js/. If you don't like that, you can change the directory names in your theme directory or even delete them completely. Hugo's nice enough to offer its opinion, then behave nicely if you disagree. + +``` +$ find themes/zafta -type d | xargs ls -ld +drwxr-xr-x 7 quoha staff 238 Sep 29 17:38 themes/zafta +drwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes/zafta/archetypes +drwxr-xr-x 5 quoha staff 170 Sep 29 17:31 themes/zafta/layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/_default +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/partials +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/static +drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/css +drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/js +$ +``` + +## The Theme Development Cycle + +When you're working on a theme, you will make changes in the theme's directory, rebuild the site, and check your changes in the browser. Hugo makes this very easy: + +1. Purge the public/ directory. +2. Run the built in web server in watch mode. +3. Open your site in a browser. +4. Update the theme. +5. Glance at your browser window to see changes. +6. Return to step 4. + +I’ll throw in one more opinion: never work on a theme on a live site. Always work on a copy of your site. Make changes to your theme, test them, then copy them up to your site. For added safety, use a tool like Git to keep a revision history of your content and your theme. Believe me when I say that it is too easy to lose both your mind and your changes. + +Check the main Hugo site for information on using Git with Hugo. + +### Purge the public/ Directory + +When generating the site, Hugo will create new files and update existing ones in the ```public/``` directory. It will not delete files that are no longer used. For example, files that were created in the wrong directory or with the wrong title will remain. If you leave them, you might get confused by them later. I recommend cleaning out your site prior to generating it. + +Note: If you're building on an SSD, you should ignore this. Churning on a SSD can be costly. + +### Hugo's Watch Option + +Hugo's "`--watch`" option will monitor the content/ and your theme directories for changes and rebuild the site automatically. + +### Live Reload + +Hugo's built in web server supports live reload. As pages are saved on the server, the browser is told to refresh the page. Usually, this happens faster than you can say, "Wow, that's totally amazing." + +### Development Commands + +Use the following commands as the basis for your workflow. + +``` +## purge old files. hugo will recreate the public directory. +## +$ rm -rf public +## +## run hugo in watch mode +## +$ hugo server --watch --verbose +``` + +Here's sample output showing Hugo detecting a change to the template for the home page. Once generated, the web browser automatically reloaded the page. I've said this before, it's amazing. + + +``` +$ rm -rf public +$ hugo server --watch --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +Watching for changes in /Users/quoha/Sites/zafta/content +Serving pages from /Users/quoha/Sites/zafta/public +Web Server is available at http://localhost:1313 +Press Ctrl+C to stop +INFO: 2014/09/29 File System Event: ["/Users/quoha/Sites/zafta/themes/zafta/layouts/index.html": MODIFY|ATTRIB] +Change detected, rebuilding site + +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 1 ms +``` + +## Update the Home Page Template + +The home page is one of a few special pages that Hugo creates automatically. As mentioned earlier, it looks for one of three files in the theme's layout/ directory: + +1. index.html +2. _default/list.html +3. _default/single.html + +We could update one of the default templates, but a good design decision is to update the most specific template available. That's not a hard and fast rule (in fact, we'll break it a few times in this tutorial), but it is a good generalization. + +### Make a Static Home Page + +Right now, that page is empty because we don't have any content and we don't have any logic in the template. Let's change that by adding some text to the template. + +``` +$ vi themes/zafta/layouts/index.html + + + +

hugo says hello!

+ + +:wq + +$ +``` + +Build the web site and then verify the results. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html + +$ cat public/index.html + + + +

hugo says hello!

+ +``` + +#### Live Reload + +Note: If you're running the server with the `--watch` option, you'll see different content in the file: + +``` +$ cat public/index.html + + + +

hugo says hello!

+ + +``` + +When you use `--watch`, the Live Reload script is added by Hugo. Look for live reload in the documentation to see what it does and how to disable it. + +### Build a "Dynamic" Home Page + +"Dynamic home page?" Hugo's a static web site generator, so this seems an odd thing to say. I mean let's have the home page automatically reflect the content in the site every time Hugo builds it. We'll use iteration in the template to do that. + +#### Create New Posts + +Now that we have the home page generating static content, let's add some content to the site. We'll display these posts as a list on the home page and on their own page, too. + +Hugo has a command to generate a skeleton post, just like it does for sites and themes. + +``` +$ hugo --verbose new post/first.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/first.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/default.md +ERROR: 2014/09/29 Unable to Cast to map[string]interface{} + +$ +``` + +That wasn't very nice, was it? + +The "new" command uses an archetype to create the post file. Hugo created an empty default archetype file, but that causes an error when there's a theme. For me, the workaround was to create an archetypes file specifically for the post type. + +``` +$ vi themes/zafta/archetypes/post.md ++++ +Description = "" +Tags = [] +Categories = [] ++++ +:wq + +$ find themes/zafta/archetypes -type f | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 21:53 themes/zafta/archetypes/default.md +-rw-r--r-- 1 quoha staff 51 Sep 29 21:54 themes/zafta/archetypes/post.md + +$ hugo --verbose new post/first.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/first.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.md +INFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/first.md +/Users/quoha/Sites/zafta/content/post/first.md created + +$ hugo --verbose new post/second.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/second.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.md +INFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/second.md +/Users/quoha/Sites/zafta/content/post/second.md created + +$ ls -l content/post +total 16 +-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md +-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md + +$ cat content/post/first.md ++++ +Categories = [] +Description = "" +Tags = [] +date = "2014-09-29T21:54:53-05:00" +title = "first" + ++++ +my first post + +$ cat content/post/second.md ++++ +Categories = [] +Description = "" +Tags = [] +date = "2014-09-29T21:57:09-05:00" +title = "second" + ++++ +my second post + +$ +``` + +Build the web site and then verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms +$ +``` + +The output says that it created 2 pages. Those are our new posts: + +``` +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 78 Sep 29 22:13 public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/second/index.html +$ +``` + +The new files are empty because because the templates used to generate the content are empty. The homepage doesn't show the new content, either. We have to update the templates to add the posts. + +### List and Single Templates + +In Hugo, we have three major kinds of templates. There's the home page template that we updated previously. It is used only by the home page. We also have "single" templates which are used to generate output for a single content file. We also have "list" templates that are used to group multiple pieces of content before generating output. + +Generally speaking, list templates are named "list.html" and single templates are named "single.html." + +There are three other types of templates: partials, content views, and terms. We will not go into much detail on these. + +### Add Content to the Homepage + +The home page will contain a list of posts. Let's update its template to add the posts that we just created. The logic in the template will run every time we build the site. + +``` +$ vi themes/zafta/layouts/index.html + + + + {{ range first 10 .Data.Pages }} +

{{ .Title }}

+ {{ end }} + + +:wq + +$ +``` + +Hugo uses the Go template engine. That engine scans the template files for commands which are enclosed between "{{" and "}}". In our template, the commands are: + +1. range +2. .Title +3. end + +The "range" command is an iterator. We're going to use it to go through the first ten pages. Every HTML file that Hugo creates is treated as a page, so looping through the list of pages will look at every file that will be created. + +The ".Title" command prints the value of the "title" variable. Hugo pulls it from the front matter in the Markdown file. + +The "end" command signals the end of the range iterator. The engine loops back to the top of the iteration when it finds "end." Everything between the "range" and "end" is evaluated every time the engine goes through the iteration. In this file, that would cause the title from the first ten pages to be output as heading level one. + +It's helpful to remember that some variables, like .Data, are created before any output files. Hugo loads every content file into the variable and then gives the template a chance to process before creating the HTML files. + +Build the web site and then verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html +$ cat public/index.html + + + + +

second

+ +

first

+ + + +$ +``` + +Congratulations, the home page shows the title of the two posts. The posts themselves are still empty, but let's take a moment to appreciate what we've done. Your template now generates output dynamically. Believe it or not, by inserting the range command inside of those curly braces, you've learned everything you need to know to build a theme. All that's really left is understanding which template will be used to generate each content file and becoming familiar with the commands for the template engine. + +And, if that were entirely true, this tutorial would be much shorter. There are a few things to know that will make creating a new template much easier. Don't worry, though, that's all to come. + +### Add Content to the Posts + +We're working with posts, which are in the content/post/ directory. That means that their section is "post" (and if we don't do something weird, their type is also "post"). + +Hugo uses the section and type to find the template file for every piece of content. Hugo will first look for a template file that matches the section or type name. If it can't find one, then it will look in the _default/ directory. There are some twists that we'll cover when we get to categories and tags, but for now we can assume that Hugo will try post/single.html, then _default/single.html. + +Now that we know the search rule, let's see what we actually have available: + +``` +$ find themes/zafta -name single.html | xargs ls -l +-rw-r--r-- 1 quoha staff 132 Sep 29 17:31 themes/zafta/layouts/_default/single.html +``` + +We could create a new template, post/single.html, or change the default. Since we don't know of any other content types, let's start with updating the default. + +Remember, any content that we haven't created a template for will end up using this template. That can be good or bad. Bad because I know that we're going to be adding different types of content and we're going to end up undoing some of the changes we've made. It's good because we'll be able to see immediate results. It's also good to start here because we can start to build the basic layout for the site. As we add more content types, we'll refactor this file and move logic around. Hugo makes that fairly painless, so we'll accept the cost and proceed. + +Please see the Hugo documentation on template rendering for all the details on determining which template to use. And, as the docs mention, if you're building a single page application (SPA) web site, you can delete all of the other templates and work with just the default single page. That's a refreshing amount of joy right there. + +#### Update the Template File + +``` +$ vi themes/zafta/layouts/_default/single.html + + + + {{ .Title }} + + +

{{ .Title }}

+ {{ .Content }} + + +:wq + +$ +``` + +Build the web site and verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 94 Sep 29 22:40 public/index.html +-rw-r--r-- 1 quoha staff 125 Sep 29 22:40 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html +-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html + +$ cat public/post/first/index.html + + + + first + + +

first

+

my first post

+ + + + +$ cat public/post/second/index.html + + + + second + + +

second

+

my second post

+ + + +$ +``` + +Notice that the posts now have content. You can go to localhost:1313/post/first to verify. + +### Linking to Content + +The posts are on the home page. Let's add a link from there to the post. Since this is the home page, we'll update its template. + +``` +$ vi themes/zafta/layouts/index.html + + + + {{ range first 10 .Data.Pages }} +

{{ .Title }}

+ {{ end }} + + +``` + +Build the web site and verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 149 Sep 29 22:44 public/index.html +-rw-r--r-- 1 quoha staff 125 Sep 29 22:44 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html +-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html + +$ cat public/index.html + + + + +

second

+ +

first

+ + + + +$ +``` + +### Create a Post Listing + +We have the posts displaying on the home page and on their own page. We also have a file public/post/index.html that is empty. Let's make it show a list of all posts (not just the first ten). + +We need to decide which template to update. This will be a listing, so it should be a list template. Let's take a quick look and see which list templates are available. + +``` +$ find themes/zafta -name list.html | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +``` + +As with the single post, we have to decide to update _default/list.html or create post/list.html. We still don't have multiple content types, so let's stay consistent and update the default list template. + +## Creating Top Level Pages + +Let's add an "about" page and display it at the top level (as opposed to a sub-level like we did with posts). + +The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let's verify that by creating an "about" page at the top level: + +``` +$ vi content/about.md ++++ +title = "about" +description = "about this site" +date = "2014-09-27" +slug = "about time" ++++ + +## about us + +i'm speechless +:wq +``` + +Generate the web site and verify the results. + +``` +$ find public -name '*.html' | xargs ls -l +-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:08 public/about-time/index.html +-rw-rw-r-- 1 mdhender staff 527 Sep 27 15:08 public/index.html +-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:08 public/post/first-post/index.html +-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:08 public/post/index.html +-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:08 public/post/second-post/index.html +``` + +Notice that the page wasn't created at the top level. It was created in a sub-directory named 'about-time/'. That name came from our slug. Hugo will use the slug to name the generated content. It's a reasonable default, by the way, but we can learn a few things by fighting it for this file. + +One other thing. Take a look at the home page. + +``` +$ cat public/index.html + + + +

creating a new theme

+

about

+

second

+

first

+ + +``` + +Notice that the "about" link is listed with the posts? That's not desirable, so let's change that first. + +``` +$ vi themes/zafta/layouts/index.html + + + +

posts

+ {{ range first 10 .Data.Pages }} + {{ if eq .Type "post"}} +

{{ .Title }}

+ {{ end }} + {{ end }} + +

pages

+ {{ range .Data.Pages }} + {{ if eq .Type "page" }} +

{{ .Title }}

+ {{ end }} + {{ end }} + + +:wq +``` + +Generate the web site and verify the results. The home page has two sections, posts and pages, and each section has the right set of headings and links in it. + +But, that about page still renders to about-time/index.html. + +``` +$ find public -name '*.html' | xargs ls -l +-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:33 public/about-time/index.html +-rw-rw-r-- 1 mdhender staff 645 Sep 27 15:33 public/index.html +-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:33 public/post/first-post/index.html +-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:33 public/post/index.html +-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:33 public/post/second-post/index.html +``` + +Knowing that hugo is using the slug to generate the file name, the simplest solution is to change the slug. Let's do it the hard way and change the permalink in the configuration file. + +``` +$ vi config.toml +[permalinks] + page = "/:title/" + about = "/:filename/" +``` + +Generate the web site and verify that this didn't work. Hugo lets "slug" or "URL" override the permalinks setting in the configuration file. Go ahead and comment out the slug in content/about.md, then generate the web site to get it to be created in the right place. + +## Sharing Templates + +If you've been following along, you probably noticed that posts have titles in the browser and the home page doesn't. That's because we didn't put the title in the home page's template (layouts/index.html). That's an easy thing to do, but let's look at a different option. + +We can put the common bits into a shared template that's stored in the themes/zafta/layouts/partials/ directory. + +### Create the Header and Footer Partials + +In Hugo, a partial is a sugar-coated template. Normally a template reference has a path specified. Partials are different. Hugo searches for them along a TODO defined search path. This makes it easier for end-users to override the theme's presentation. + +``` +$ vi themes/zafta/layouts/partials/header.html + + + + {{ .Title }} + + +:wq + +$ vi themes/zafta/layouts/partials/footer.html + + +:wq +``` + +### Update the Home Page Template to Use the Partials + +The most noticeable difference between a template call and a partials call is the lack of path: + +``` +{{ template "theme/partials/header.html" . }} +``` +versus +``` +{{ partial "header.html" . }} +``` +Both pass in the context. + +Let's change the home page template to use these new partials. + +``` +$ vi themes/zafta/layouts/index.html +{{ partial "header.html" . }} + +

posts

+ {{ range first 10 .Data.Pages }} + {{ if eq .Type "post"}} +

{{ .Title }}

+ {{ end }} + {{ end }} + +

pages

+ {{ range .Data.Pages }} + {{ if or (eq .Type "page") (eq .Type "about") }} +

{{ .Type }} - {{ .Title }} - {{ .RelPermalink }}

+ {{ end }} + {{ end }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The title on the home page is now "your title here", which comes from the "title" variable in the config.toml file. + +### Update the Default Single Template to Use the Partials + +``` +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The title on the posts and the about page should both reflect the value in the markdown file. + +## Add “Date Published” to Posts + +It's common to have posts display the date that they were written or published, so let's add that. The front matter of our posts has a variable named "date." It's usually the date the content was created, but let's pretend that's the value we want to display. + +### Add “Date Published” to the Template + +We'll start by updating the template used to render the posts. The template code will look like: + +``` +{{ .Date.Format "Mon, Jan 2, 2006" }} +``` + +Posts use the default single template, so we'll change that file. + +``` +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+

{{ .Date.Format "Mon, Jan 2, 2006" }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The posts now have the date displayed in them. There's a problem, though. The "about" page also has the date displayed. + +As usual, there are a couple of ways to make the date display only on posts. We could do an "if" statement like we did on the home page. Another way would be to create a separate template for posts. + +The "if" solution works for sites that have just a couple of content types. It aligns with the principle of "code for today," too. + +Let's assume, though, that we've made our site so complex that we feel we have to create a new template type. In Hugo-speak, we're going to create a section template. + +Let's restore the default single template before we forget. + +``` +$ mkdir themes/zafta/layouts/post +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Now we'll update the post's version of the single template. If you remember Hugo's rules, the template engine will use this version over the default. + +``` +$ vi themes/zafta/layouts/post/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+

{{ .Date.Format "Mon, Jan 2, 2006" }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq + +``` + +Note that we removed the date logic from the default template and put it in the post template. Generate the web site and verify the results. Posts have dates and the about page doesn't. + +### Don't Repeat Yourself + +DRY is a good design goal and Hugo does a great job supporting it. Part of the art of a good template is knowing when to add a new template and when to update an existing one. While you're figuring that out, accept that you'll be doing some refactoring. Hugo makes that easy and fast, so it's okay to delay splitting up a template. diff --git a/exampleSite/content/posts/goisforlovers.md b/exampleSite/content/posts/goisforlovers.md new file mode 100644 index 0000000..41d20f1 --- /dev/null +++ b/exampleSite/content/posts/goisforlovers.md @@ -0,0 +1,343 @@ ++++ +title = "(Hu)go Template Primer" +description = "" +tags = [ + "go", + "golang", + "templates", + "themes", + "development", +] +date = "2014-04-02" +categories = [ + "Development", + "golang", +] ++++ + +Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for +its template engine. It is an extremely lightweight engine that provides a very +small amount of logic. In our experience that it is just the right amount of +logic to be able to create a good static website. If you have used other +template systems from different languages or frameworks you will find a lot of +similarities in go templates. + +This document is a brief primer on using go templates. The [go docs][gohtmltemplate] +provide more details. + +## Introduction to Go Templates + +Go templates provide an extremely simple template language. It adheres to the +belief that only the most basic of logic belongs in the template or view layer. +One consequence of this simplicity is that go templates parse very quickly. + +A unique characteristic of go templates is they are content aware. Variables and +content will be sanitized depending on the context of where they are used. More +details can be found in the [go docs][gohtmltemplate]. + +## Basic Syntax + +Go lang templates are html files with the addition of variables and +functions. + +**Go variables and functions are accessible within {{ }}** + +Accessing a predefined variable "foo": + + {{ foo }} + +**Parameters are separated using spaces** + +Calling the add function with input of 1, 2: + + {{ add 1 2 }} + +**Methods and fields are accessed via dot notation** + +Accessing the Page Parameter "bar" + + {{ .Params.bar }} + +**Parentheses can be used to group items together** + + {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }} + + +## Variables + +Each go template has a struct (object) made available to it. In hugo each +template is passed either a page or a node struct depending on which type of +page you are rendering. More details are available on the +[variables](/layout/variables) page. + +A variable is accessed by referencing the variable name. + + {{ .Title }} + +Variables can also be defined and referenced. + + {{ $address := "123 Main St."}} + {{ $address }} + + +## Functions + +Go template ship with a few functions which provide basic functionality. The go +template system also provides a mechanism for applications to extend the +available functions with their own. [Hugo template +functions](/layout/functions) provide some additional functionality we believe +are useful for building websites. Functions are called by using their name +followed by the required parameters separated by spaces. Template +functions cannot be added without recompiling hugo. + +**Example:** + + {{ add 1 2 }} + +## Includes + +When including another template you will pass to it the data it will be +able to access. To pass along the current context please remember to +include a trailing dot. The templates location will always be starting at +the /layout/ directory within Hugo. + +**Example:** + + {{ template "chrome/header.html" . }} + + +## Logic + +Go templates provide the most basic iteration and conditional logic. + +### Iteration + +Just like in go, the go templates make heavy use of range to iterate over +a map, array or slice. The following are different examples of how to use +range. + +**Example 1: Using Context** + + {{ range array }} + {{ . }} + {{ end }} + +**Example 2: Declaring value variable name** + + {{range $element := array}} + {{ $element }} + {{ end }} + +**Example 2: Declaring key and value variable name** + + {{range $index, $element := array}} + {{ $index }} + {{ $element }} + {{ end }} + +### Conditionals + +If, else, with, or, & and provide the framework for handling conditional +logic in Go Templates. Like range, each statement is closed with `end`. + + +Go Templates treat the following values as false: + +* false +* 0 +* any array, slice, map, or string of length zero + +**Example 1: If** + + {{ if isset .Params "title" }}

{{ index .Params "title" }}

{{ end }} + +**Example 2: If -> Else** + + {{ if isset .Params "alt" }} + {{ index .Params "alt" }} + {{else}} + {{ index .Params "caption" }} + {{ end }} + +**Example 3: And & Or** + + {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} + +**Example 4: With** + +An alternative way of writing "if" and then referencing the same value +is to use "with" instead. With rebinds the context `.` within its scope, +and skips the block if the variable is absent. + +The first example above could be simplified as: + + {{ with .Params.title }}

{{ . }}

{{ end }} + +**Example 5: If -> Else If** + + {{ if isset .Params "alt" }} + {{ index .Params "alt" }} + {{ else if isset .Params "caption" }} + {{ index .Params "caption" }} + {{ end }} + +## Pipes + +One of the most powerful components of go templates is the ability to +stack actions one after another. This is done by using pipes. Borrowed +from unix pipes, the concept is simple, each pipeline's output becomes the +input of the following pipe. + +Because of the very simple syntax of go templates, the pipe is essential +to being able to chain together function calls. One limitation of the +pipes is that they only can work with a single value and that value +becomes the last parameter of the next pipeline. + +A few simple examples should help convey how to use the pipe. + +**Example 1 :** + + {{ if eq 1 1 }} Same {{ end }} + +is the same as + + {{ eq 1 1 | if }} Same {{ end }} + +It does look odd to place the if at the end, but it does provide a good +illustration of how to use the pipes. + +**Example 2 :** + + {{ index .Params "disqus_url" | html }} + +Access the page parameter called "disqus_url" and escape the HTML. + +**Example 3 :** + + {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} + Stuff Here + {{ end }} + +Could be rewritten as + + {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }} + Stuff Here + {{ end }} + + +## Context (aka. the dot) + +The most easily overlooked concept to understand about go templates is that {{ . }} +always refers to the current context. In the top level of your template this +will be the data set made available to it. Inside of a iteration it will have +the value of the current item. When inside of a loop the context has changed. . +will no longer refer to the data available to the entire page. If you need to +access this from within the loop you will likely want to set it to a variable +instead of depending on the context. + +**Example:** + + {{ $title := .Site.Title }} + {{ range .Params.tags }} +
  • {{ . }} - {{ $title }}
  • + {{ end }} + +Notice how once we have entered the loop the value of {{ . }} has changed. We +have defined a variable outside of the loop so we have access to it from within +the loop. + +# Hugo Parameters + +Hugo provides the option of passing values to the template language +through the site configuration (for sitewide values), or through the meta +data of each specific piece of content. You can define any values of any +type (supported by your front matter/config format) and use them however +you want to inside of your templates. + + +## Using Content (page) Parameters + +In each piece of content you can provide variables to be used by the +templates. This happens in the [front matter](/content/front-matter). + +An example of this is used in this documentation site. Most of the pages +benefit from having the table of contents provided. Sometimes the TOC just +doesn't make a lot of sense. We've defined a variable in our front matter +of some pages to turn off the TOC from being displayed. + +Here is the example front matter: + +``` +--- +title: "Permalinks" +date: "2013-11-18" +aliases: + - "/doc/permalinks/" +groups: ["extras"] +groups_weight: 30 +notoc: true +--- +``` + +Here is the corresponding code inside of the template: + + {{ if not .Params.notoc }} +
    + {{ .TableOfContents }} +
    + {{ end }} + + + +## Using Site (config) Parameters +In your top-level configuration file (eg, `config.yaml`) you can define site +parameters, which are values which will be available to you in chrome. + +For instance, you might declare: + +```yaml +params: + CopyrightHTML: "Copyright © 2013 John Doe. All Rights Reserved." + TwitterUser: "spf13" + SidebarRecentLimit: 5 +``` + +Within a footer layout, you might then declare a `