Initial commit

This commit is contained in:
Sagi Dayan 2019-07-25 17:13:27 -04:00
commit fe852b17c2
79 changed files with 7861 additions and 0 deletions

60
.eslintrc.yml Normal file
View file

@ -0,0 +1,60 @@
---
env:
es6: true
extends:
# https://github.com/airbnb/javascript
- airbnb
- eslint:recommended
- prettier
parser: babel-eslint
rules:
# best practices
arrow-parens:
- 2
- as-needed
semi:
- 2
- never
class-methods-use-this: 0
comma-dangle:
- 2
- always-multiline
no-console:
- 2
no-unused-expressions: 0
no-param-reassign:
- 2
- props: false
no-useless-escape: 0
func-names: 0
quotes:
- 2
- single
- allowTemplateLiterals: true
no-underscore-dangle: 0
object-curly-newline: 0
function-paren-newline: 0
operator-linebreak:
- 2
- after
no-unused-vars:
- 2
- argsIgnorePattern: "^_"
# jsx a11y
jsx-a11y/no-static-element-interactions: 0
jsx-a11y/anchor-is-valid:
- 2
- specialLink:
- to
globals:
document: true
requestAnimationFrame: true
window: true
self: true
fetch: true
Headers: true

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules

5
.prettierrc Normal file
View file

@ -0,0 +1,5 @@
{
"parser": "babylon",
"printWidth": 100,
"trailingComma": "all"
}

12
LICENSE.md Normal file
View file

@ -0,0 +1,12 @@
The MIT License (MIT)
Original work Copyright (c) 2018 Track3<br />
Original work Copyright (c) 2019 panr<br />
Modified work Copyright (c) 2019 Djordje Atlialp<br />
Modified work Copyright (c) 2019 Sagi Dayan<br />
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.

174
README.md Normal file
View file

@ -0,0 +1,174 @@
# Hello Amigo
A minimalistic theme for [hugo](https://gohugo.io).
This theme is a HARD fork of [Hello Friend NG](https://github.com/rhazdon/hugo-theme-hello-friend-ng) made by [rhazdon](https://github.com/rhazdon).
## Why fork?
Wanted to change up, colors, icons, fonts and a bit more.
## Features
- Theming: **dark/light mode**, depending on your preferences (dark is default, but you can change it)
- Great reading experience thanks to [**Inter UI font**](https://rsms.me/inter/), made by [Rasmus Andersson](https://rsms.me/about/)
- Nice code highlighting thanks to [**PrismJS**](https://prismjs.com)
- An easy way to modify the theme with Hugo tooling
- Fully responsive
- Support for social
#### Built-in shortcodes
- **`image`** (prop required: **`src`**; props optional: **`alt`**, **`position`** (**left** is default | center | right), **`style`**)
- eg: `{{< image src="/img/hello.png" alt="Hello Friend" position="center" style="border-radius: 8px;" >}}`
- **`figure`** (same as `image`, plus few optional props: **`caption`**, **`captionPosition`** (left | **center** is default | right), **`captionStyle`**
- eg: `{{< figure src="/img/hello.png" alt="Hello Friend" position="center" style="border-radius: 8px;" caption="Hello Friend!" captionPosition="right" captionStyle="color: red;" >}}`
#### Code highlighting
By default the theme is using PrismJS to color your code syntax. All you need to do is to wrap you code like this:
<pre>
```html
// your code here
```
</pre>
**Supported languages**: https://prismjs.com/#languages-list
## How to start
You can download the theme manually by going to [https://github.com/rhazdon/hugo-theme-hello-friend-ng.git](https://github.com/rhazdon/hugo-theme-hello-friend-ng.git) and pasting it to `themes/hello-amigo` in your root directory.
You can also clone it directly to your Hugo folder:
```
$ git clone https://github.com/rhazdon/hugo-theme-hello-friend-ng.git themes/hello-friend-ng
```
If you don't want to make any radical changes, it's the best option, because you can get new updates when they are available. To do so, include it as a git submodule:
```
$ git submodule add https://github.com/rhazdon/hugo-theme-hello-friend-ng.git themes/hello-friend-ng
```
### Favicon
Use [RealFaviconGenerator](https://realfavicongenerator.net/) to generate these files, put them into your site's static folder:
- android-chrome-192x192.png
- android-chrome-512x512.png
- apple-touch-icon.png
- favicon-16x16.png
- favicon-32x32.png
- favicon.ico
- mstile-150x150.png
- safari-pinned-tab.svg
- site.webmanifest
## How to configure
The theme doesn't require any advanced configuration. Just copy:
```
baseurl = "/"
languageCode = "en-us"
theme = "hello-amigo"
[params]
dateform = "Jan 2, 2006"
dateformShort = "Jan 2"
dateformNum = "2006-01-02"
dateformNumTime = "2006-01-02 15:04 -0700"
# Metadata mostly used in document's head
description = "Homepage and blog by Djordje Atlialp"
keywords = "homepage, blog, science, informatics, development, programming"
images = [""]
# Directory name of your blog content (default is `content/posts`)
contentTypeName = "posts"
# Default theme "light" or "dark"
defaultTheme = "dark"
[languages]
[languages.en]
title = "Hello Amigo"
subtitle = "A simple theme for Hugo"
keywords = ""
copyright = ""
readOtherPosts = "Read other posts"
[languages.en.params.logo]
logoText = "hello friend ng"
logoHomeLink = "/"
# or
#
# path = "/img/your-example-logo.svg"
# alt = "Your example logo alt text"
# You can create a language based menu
[languages.en.menu]
[[languages.en.menu.main]]
identifier = "about"
name = "About"
url = "/about"
[[languages.en.menu.main]]
identifier = "showcase"
name = "Showcase"
url = "/showcase"
# And you can even create generic menu
[menu]
[[menu.main]]
identifier = "about"
name = "About"
url = "/about"
[[menu.main]]
identifier = "blog"
name = "Blog"
url = "/posts"
```
## How to run your site
From your Hugo root directory run:
```
$ hugo server -t hello-friend-ng
```
and go to `localhost:1313` in your browser. From now on all the changes you make will go live, so you don't need to refresh your browser every single time.
## How to edit the theme
If you really want to edit the theme, you need to install Node dependencies. To do this, go to the theme directory (from your Hugo root directory):
```
$ cd themes/hello-friend-ng
```
and then run:
```
$ npm install
```
## How to contribute
If you spot any bugs, please use [Issue Tracker](https://github.com/rhazdon/hugo-theme-hello-friend-ng/issues) or if you want to add a new feature directly please create a new [Pull Request](https://github.com/rhazdon/hugo-theme-hello-friend-ng/pulls).
## Third Party
- [normalize.css](https://github.com/necolas/normalize.css)
- [Feather Open Source Icons](https://github.com/feathericons/feather)
- [Flag Icon](https://github.com/lipis/flag-icon-css)
## Licence
The theme is released under the MIT License. Check the [original theme license](https://github.com/rhazdon/hugo-theme-hello-friend-ng/blob/master/LICENSE.md) for additional licensing information.

8
archetypes/default.md Normal file
View file

@ -0,0 +1,8 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
comments: false
images:
---

10
archetypes/posts.md Normal file
View file

@ -0,0 +1,10 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
toc: false
images:
tags:
- untagged
---

1
assets/js/main.js Normal file
View file

@ -0,0 +1 @@
// Some code could be here ...

16
assets/js/menu.js Normal file
View file

@ -0,0 +1,16 @@
// Mobile menu
const menuTrigger = document.querySelector(".menu-trigger");
const menu = document.querySelector(".menu");
const mobileQuery = getComputedStyle(document.body).getPropertyValue("--phoneWidth");
const isMobile = () => window.matchMedia(mobileQuery).matches;
const isMobileMenu = () => {
menuTrigger && menuTrigger.classList.toggle("hidden", !isMobile());
menu && menu.classList.toggle("hidden", isMobile());
};
isMobileMenu();
menuTrigger && menuTrigger.addEventListener("click", () => menu && menu.classList.toggle("hidden"));
window.addEventListener("resize", isMobileMenu);

163
assets/js/prism.js Normal file

File diff suppressed because one or more lines are too long

23
assets/js/theme.js Normal file
View file

@ -0,0 +1,23 @@
// Toggle theme
const getTheme = window.localStorage && window.localStorage.getItem("theme");
const themeToggle = document.querySelector(".theme-toggle");
const isDark = getTheme === "dark";
var metaThemeColor = document.querySelector("meta[name=theme-color]");
if (getTheme !== null) {
document.body.classList.toggle("dark-theme", isDark);
isDark ? metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
}
themeToggle.addEventListener("click", () => {
document.body.classList.toggle("dark-theme");
window.localStorage &&
window.localStorage.setItem(
"theme",
document.body.classList.contains("dark-theme") ? "dark" : "light",
);
document.body.classList.contains("dark-theme") ?
metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
;
});

99
assets/scss/_buttons.scss Normal file
View file

@ -0,0 +1,99 @@
.button-container {
display: table;
margin-left: auto;
margin-right: auto;
}
button,
.button,
a.button {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 8px 18px;
margin-bottom: 5px;
background: $light-background-secondary;
text-decoration: none;
text-align: center;
font-weight: 500;
border-radius: 8px;
border: 1px solid transparent;
appearance: none;
cursor: pointer;
outline: none;
.dark-theme & {
background: $dark-background-secondary;
color: inherit;
}
/* variants */
&.outline {
background: transparent;
border-color: $light-background-secondary;
box-shadow: none;
padding: 8px 18px;
.dark-theme & {
border-color: $dark-background-secondary;
color: inherit;
}
:hover {
transform: none;
box-shadow: none;
}
}
&.primary {
box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
&:hover {
box-shadow: 0 2px 6px rgba(50, 50, 93, .21), 0 1px 3px rgba(0, 0, 0, .08);
}
}
&.link {
background: none;
font-size: 1rem;
}
&.small {
font-size: .8rem;
}
&.wide {
min-width: 200px;
padding: 14px 24px;
}
}
.code-toolbar {
margin-bottom: 20px;
.toolbar-item a {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 3px 8px;
margin-bottom: 5px;
background: $light-background-secondary;
text-decoration: none;
text-align: center;
font-size: 13px;
font-weight: 500;
border-radius: 8px;
border: 1px solid transparent;
appearance: none;
cursor: pointer;
outline: none;
.dark-theme & {
background: $dark-background-secondary;
color: inherit;
}
}
}

50
assets/scss/_fonts.scss Normal file
View file

@ -0,0 +1,50 @@
@font-face {
font-family: 'Inter UI';
font-style: normal;
font-display: auto;
font-weight: 400;
src: url("../fonts/Inter-UI-Regular.woff2") format("woff2"),
url("../fonts/Inter-UI-Regular.woff") format("woff");
}
@font-face {
font-family: 'Inter UI';
font-style: italic;
font-display: auto;
font-weight: 400;
src: url("../fonts/Inter-UI-Italic.woff2") format("woff2"),
url("../fonts/Inter-UI-Italic.woff") format("woff");
}
@font-face {
font-family: 'Inter UI';
font-style: normal;
font-display: auto;
font-weight: 600;
src: url("../fonts/Inter-UI-Medium.woff2") format("woff2"),
url("../fonts/Inter-UI-Medium.woff") format("woff");
}
@font-face {
font-family: 'Inter UI';
font-style: italic;
font-display: auto;
font-weight: 600;
src: url("../fonts/Inter-UI-MediumItalic.woff2") format("woff2"),
url("../fonts/Inter-UI-MediumItalic.woff") format("woff");
}
@font-face {
font-family: 'Inter UI';
font-style: normal;
font-display: auto;
font-weight: 800;
src: url("../fonts/Inter-UI-Bold.woff2") format("woff2"),
url("../fonts/Inter-UI-Bold.woff") format("woff");
}
@font-face {
font-family: 'Inter UI';
font-style: italic;
font-display: auto;
font-weight: 800;
src: url("../fonts/Inter-UI-BoldItalic.woff2") format("woff2"),
url("../fonts/Inter-UI-BoldItalic.woff") format("woff");
}

44
assets/scss/_footer.scss Normal file
View file

@ -0,0 +1,44 @@
.footer {
padding: 40px 20px;
flex-grow: 0;
color: $light-color-secondary;
&__inner {
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
width: 760px;
max-width: 100%;
@media #{$media-size-tablet} {
flex-direction: column;
}
}
&__content {
display: flex;
flex-direction: row;
align-items: center;
font-size: 1rem;
color: $light-color-secondary;
@media #{$media-size-tablet} {
flex-direction: column;
margin-top: 10px;
}
& > *:not(:last-child) {
border-right: 1px solid;
padding: 0 15px;
@media #{$media-size-tablet} {
border: none;
}
}
& > *:last-child {
padding: 0 15px;
}
}
}

43
assets/scss/_header.scss Normal file
View file

@ -0,0 +1,43 @@
.header {
background: #fafafa;
display: flex;
align-items: center;
justify-content: center;
position: relative;
padding: 20px;
.dark-theme & {
background: #252627;
}
&__right {
display: flex;
flex-direction: row;
align-items: center;
@media #{$media-size-phone} {
flex-direction: row-reverse;
}
}
&__inner {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
width: 760px;
max-width: 100%;
}
}
.theme-toggle {
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
cursor: pointer;
}
.theme-toggler {
fill: currentColor;
}

72
assets/scss/_list.scss Normal file
View file

@ -0,0 +1,72 @@
.posts {
width: 100%;
max-width: 800px;
text-align: left;
padding: 20px;
margin: 20px auto;
@media #{$media-size-tablet} {
max-width: 660px;
}
&:not(:last-of-type) {
border-bottom: 1px solid $light-border-color;
.dark-theme & {
border-color: $dark-border-color;
}
}
&-group {
display: flex;
margin-bottom: 1.9em;
line-height: normal;
@media #{$media-size-tablet} {
display: block;
}
}
&-list {
flex-grow: 1;
margin: 0;
padding: 0;
list-style: none;
}
.post {
&-title {
font-size: 1rem;
margin: 5px 0 5px 0;
}
&-year {
padding-top: 6px;
margin-right: 1.8em;
font-size: 1.6em;
@include dimmed;
@media #{$media-size-tablet} {
margin: -6px 0 4px;
}
}
&-item {
border-bottom: 1px grey dashed;
a {
display: flex;
justify-content: space-between;
align-items: baseline;
padding: 12px 0;
text-decoration: none;
}
}
&-day {
flex-shrink: 0;
margin-left: 1em;
@include dimmed;
}
}
}

43
assets/scss/_logo.scss Normal file
View file

@ -0,0 +1,43 @@
.logo {
display: flex;
align-items: center;
text-decoration: none;
font-weight: bold;
font-display: auto;
font-family: monospace, monospace;
img {
height: 44px;
}
&__mark {
margin-right: 5px;
}
&__text {
font-size: 1.125rem;
}
&__cursor {
display: inline-block;
width: 10px;
height: 1rem;
background: #fe5186;
margin-left: 5px;
border-radius: 1px;
animation: cursor 1s infinite;
}
@media (prefers-reduced-motion: reduce) {
&__cursor {
animation: none;
}
}
}
@keyframes cursor {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}

305
assets/scss/_main.scss Normal file
View file

@ -0,0 +1,305 @@
html {
box-sizing: border-box;
line-height: 1.6;
letter-spacing: .06em;
scroll-behavior: smooth;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
font-family: 'Inter UI', -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif;
font-display: auto;
font-size: 1rem;
line-height: 1.54;
background-color: $light-background;
color: $light-color;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
font-feature-settings: "liga", "tnum", "case", "calt", "zero", "ss01", "locl";
-webkit-overflow-scrolling: touch;
-webkit-text-size-adjust: 100%;
display: flex;
min-height: 100vh;
flex-direction: column;
@media #{$media-size-phone} {
font-size: 1rem;
}
&.dark-theme {
background-color: $dark-background;
color: $dark-color;
}
}
h2, h3, h4, h5, h6 {
display: flex;
align-items: center;
line-height: 1.3;
}
h1 {
font-size: 2.625rem;
}
h2 {
font-size: 1.625rem;
}
h3 {
font-size: 1.375rem;
}
h4 {
font-size: 1.125rem;
}
@media #{$media-size-phone} {
h1 {
font-size: 2rem;
}
h2 {
font-size: 1.4rem;
}
h3 {
font-size: 1.15rem;
}
h4 {
font-size: 1.125rem;
}
}
a {
color: inherit;
}
img {
display: block;
max-width: 100%;
&.left {
margin-right: auto;
}
&.center {
margin-left: auto;
margin-right: auto;
}
&.right {
margin-left: auto;
}
}
figure {
display: table;
max-width: 100%;
margin: 25px 0;
&.left {
margin-right: auto;
}
&.center {
margin-left: auto;
margin-right: auto;
}
&.right {
margin-left: auto;
}
figcaption {
font-size: 14px;
margin-top: 5px;
opacity: .8;
&.left {
text-align: left;
}
&.center {
text-align: center;
}
&.right {
text-align: right;
}
}
}
code {
font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;
font-display: auto;
font-feature-settings: normal;
background: $light-background-secondary;
padding: 1px 6px;
margin: 0 2px;
border-radius: 5px;
font-size: .95rem;
.dark-theme & {
background: $dark-background-secondary;
}
}
pre {
background: #212020;
padding: 20px;
border-radius: 8px;
font-size: .95rem;
overflow: auto;
@media #{$media-size-phone} {
white-space: pre-wrap;
word-wrap: break-word;
}
code {
background: none !important;
color: #ccc;
margin: 0;
padding: 0;
font-size: inherit;
.dark-theme & {
color: inherit;
}
}
}
blockquote {
border-left: 2px solid;
margin: 40px;
padding: 10px 20px;
@media #{$media-size-phone} {
margin: 10px;
padding: 10px;
}
&:before {
content: '';
font-family: Georgia, serif;
font-display: auto;
font-size: 3.875rem;
position: absolute;
left: -40px;
top: -20px;
}
p:first-of-type {
margin-top: 0;
}
p:last-of-type {
margin-bottom: 0;
}
}
ul, ol {
margin-left: 40px;
padding: 0;
@media #{$media-size-phone} {
margin-left: 20px;
}
}
ol ol {
list-style-type: lower-alpha;
}
.container {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.content {
display: flex;
flex-direction: column;
flex: 1 auto;
align-items: center;
justify-content: center;
margin: 50px 0;
@media #{$media-size-phone} {
margin-top: 0;
}
}
hr {
width: 100%;
border: none;
background: $light-border-color;
height: 1px;
.dark-theme & {
background: $dark-border-color;
}
}
.hidden {
display: none;
}
.hide-on-phone {
@media #{$media-size-phone} {
display: none;
}
}
.hide-on-tablet {
@media #{$media-size-tablet} {
display: none;
}
}
// Accessibility
.screen-reader-text {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute !important;
width: 1px;
word-wrap: normal !important;
}
.screen-reader-text:focus {
background-color: #f1f1f1;
border-radius: 3px;
box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
clip: auto !important;
clip-path: none;
color: #21759b;
display: block;
font-size: 14px;
font-size: 0.875rem;
font-weight: bold;
height: auto;
left: 5px;
line-height: normal;
padding: 15px 23px 14px;
text-decoration: none;
top: 5px;
width: auto;
z-index: 100000;
}

67
assets/scss/_menu.scss Normal file
View file

@ -0,0 +1,67 @@
.menu {
background: #fafafa;
border-right: 1px solid;
margin-right: 18px;
z-index: 9999;
.dark-theme & {
background: #252627;
}
@media #{$media-size-phone} {
position: absolute;
top: 50px;
right: 0;
border: none;
margin: 0;
padding: 10px;
}
&__inner {
display: flex;
align-items: center;
justify-content: flex-start;
max-width: 100%;
margin: 0 auto;
padding: 0 15px;
font-size: 1rem;
list-style: none;
li {
margin: 0 12px;
}
@media #{$media-size-phone} {
flex-direction: column;
align-items: flex-start;
padding: 0;
li {
margin: 0;
padding: 5px;
}
}
}
&-trigger {
width: 24px;
height: 24px;
fill: currentColor;
margin-left: 10px;
cursor: pointer;
}
a {
display: inline-block;
margin-right: 15px;
text-decoration: none;
&:hover {
text-decoration: underline;
}
&:last-of-type {
margin-right: 0;
}
}
}

3
assets/scss/_mixins.scss Normal file
View file

@ -0,0 +1,3 @@
@mixin dimmed {
opacity: .6;
}

367
assets/scss/_normalize.scss Normal file
View file

@ -0,0 +1,367 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
/* Webkit Scrollbar Customize */
::-webkit-scrollbar {
width: 8px;
height: 8px;
background: #212020;
}
::-webkit-scrollbar-thumb {
background: #888;
&:hover {
background: #dcdcdc;
}
}
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-display: auto;
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-display: auto;
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-display: auto;
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}

125
assets/scss/_prism.scss Normal file
View file

@ -0,0 +1,125 @@
/* PrismJS 1.15.0
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+abap+actionscript+ada+apacheconf+apl+applescript+c+arff+asciidoc+asm6502+csharp+autohotkey+autoit+bash+basic+batch+bison+brainfuck+bro+cpp+aspnet+arduino+cil+coffeescript+clojure+ruby+csp+css-extras+d+dart+diff+django+docker+eiffel+elixir+elm+markup-templating+erlang+fsharp+flow+fortran+gcode+gedcom+gherkin+git+glsl+gml+go+graphql+groovy+less+handlebars+haskell+haxe+hcl+http+hpkp+hsts+ichigojam+icon+inform7+ini+io+j+java+javastacktrace+jolie+json+julia+keyman+kotlin+latex+markdown+liquid+lisp+livescript+lolcode+lua+makefile+crystal+erb+matlab+mel+mizar+monkey+n1ql+n4js+nand2tetris-hdl+nasm+nginx+nim+nix+nsis+objectivec+ocaml+opencl+oz+parigp+parser+pascal+perl+php+php-extras+sql+powershell+processing+prolog+properties+protobuf+scss+puppet+pure+python+q+qore+r+jsx+typescript+renpy+reason+rest+rip+roboconf+textile+rust+sas+sass+stylus+scala+scheme+smalltalk+smarty+plsql+soy+pug+swift+yaml+tcl+haml+toml+tt2+twig+tsx+vala+vbnet+velocity+verilog+vhdl+vim+visual-basic+wasm+wiki+xeora+xojo+xquery+tap */
/**
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
* Based on https://github.com/chriskempson/tomorrow-theme
* @author Rose Pritchard
*/
code[class*="language-"],
pre[class*="language-"] {
color: #ccc;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-display: auto;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #2d2d2d;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #999;
}
.token.punctuation {
color: #ccc;
}
.token.tag,
.token.attr-name,
.token.namespace,
.token.deleted {
color: #e2777a;
}
.token.function-name {
color: #6196cc;
}
.token.boolean,
.token.number,
.token.function {
color: #f08d49;
}
.token.property,
.token.class-name,
.token.constant,
.token.symbol {
color: #f8c555;
}
.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
color: #cc99cd;
}
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
color: #7ec699;
}
.token.operator,
.token.entity,
.token.url {
color: #67cdcc;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.inserted {
color: green;
}

191
assets/scss/_single.scss Normal file
View file

@ -0,0 +1,191 @@
.post {
width: 100%;
max-width: 800px;
text-align: left;
padding: 20px;
margin: 20px auto;
@media #{$media-size-tablet} {
max-width: 600px;
}
&-date {
&:after {
content: '';
}
}
&-title {
font-size: 2.625rem;
margin: 0 0 20px;
@media #{$media-size-phone} {
font-size: 2rem;
}
a {
text-decoration: none;
}
}
&-tags {
display: block;
margin-bottom: 20px;
font-size: 1rem;
opacity: .5;
a {
text-decoration: none;
}
}
&-content {
margin-top: 30px;
}
&-cover {
border-radius: 8px;
margin: 40px -50px;
width: 860px;
max-width: 860px;
@media #{$media-size-tablet} {
margin: 20px 0;
width: 100%;
}
}
&-info {
margin-top: 30px;
font-size: .8rem;
line-height: normal;
@include dimmed;
p {
margin: .8em 0;
}
a:hover {
border-bottom: 1px solid white;
}
svg {
margin-right: .8em;
}
.tag {
margin-right: .5em;
&::before {
content: "#"
}
}
.feather {
display: inline-block;
vertical-align: -.125em;
width: 1em;
height: 1em;
}
}
.flag {
border-radius: 50%;
margin: 0 5px;
}
}
.pagination {
margin-top: 20px;
&__title {
display: flex;
text-align: center;
position: relative;
margin: 30px 0 20px;
&-h {
text-align: center;
margin: 0 auto;
padding: 5px 10px;
background: $light-background;
color: $light-color-secondary;
font-size: .8rem;
text-transform: uppercase;
text-decoration: none;
letter-spacing: .1em;
z-index: 1;
.dark-theme & {
background: $dark-background;
color: $dark-color-secondary;
}
}
hr {
position: absolute;
left: 0;
right: 0;
width: 100%;
margin-top: 15px;
z-index: 0;
}
}
&__buttons {
display: flex;
align-items: center;
justify-content: center;
a {
text-decoration: none;
font-weight: bold;
}
}
}
.button {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
background: $light-background-secondary;
font-size: 1rem;
font-weight: 600;
border-radius: 8px;
max-width: 40%;
padding: 0;
cursor: pointer;
appearance: none;
.dark-theme & {
background: $dark-background-secondary;
}
+ .button {
margin-left: 10px;
}
a {
display: flex;
padding: 8px 16px;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
&__text {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
&.next .button__icon {
margin-left: 8px;
}
&.previous .button__icon {
margin-right: 8px;
}
}

View file

@ -0,0 +1,24 @@
@charset "UTF-8";
/* light theme color */
$light-background: #fff;
$light-background-secondary: #eaeaea;
$light-color: #222;
$light-color-secondary: #999;
$light-border-color: #dcdcdc;
/* dark theme colors */
$dark-background: #292a2d;
$dark-background-secondary: #3b3d42;
$dark-color: #a9a9b3;
$dark-color-secondary: #73747b;
$dark-border-color: #4a4b50;
$media-size-phone: "(max-width: 684px)";
$media-size-tablet: "(max-width: 900px)";
/* variables for js, must be the same as these in @custom-media queries */
:root {
--phoneWidth: (max-width: 684px);
--tabletWidth: (max-width: 900px);
}

15
assets/scss/main.scss Normal file
View file

@ -0,0 +1,15 @@
@import "normalize";
@import "prism";
@import "variables";
@import "mixins";
@import "fonts";
@import "buttons";
@import "header";
@import "logo";
@import "menu";
@import "main";
@import "list";
@import "single";
@import "footer";

6
data/langFlags.yaml Normal file
View file

@ -0,0 +1,6 @@
de: de
en: gb
fr: fr
nl: nl
es: es
pt-br: br

120
exampleSite/config.toml Normal file
View file

@ -0,0 +1,120 @@
baseURL = "https://example.com"
title = "Hello Friend NG"
DefaultContentLanguage = "en"
theme = "hello-friend-ng"
PygmentsCodeFences = true
PygmentsStyle = "monokai"
rssLimit = 10 # Maximum number of items in the RSS feed.
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License." # This message is only used by the RSS template.
# googleAnalytics = ""
# disqusShortname = ""
archetypeDir = "archetypes"
contentDir = "content"
dataDir = "data"
layoutDir = "layouts"
publishDir = "public"
buildDrafts = false
buildFuture = false
buildExpored = false
canonifyURLs = true
enableRobotsTXT = true
enableGitInfo = false
enableEmoji = true
enableMissingTranslationPlaceholders = false
disableRSS = false
disableSitemap = false
disable404 = false
disableHugoGeneratorInject = false
[permalinks]
posts = "/posts/:year/:month/:title/"
[author]
name = "Jane Doe"
[blackfriday]
hrefTargetBlank = true
[taxonomies]
tag = "tags"
category = ""
[params]
dateform = "Jan 2, 2006"
dateformShort = "Jan 2"
dateformNum = "2006-01-02"
dateformNumTime = "2006-01-02 15:04 -0700"
# Metadata mostly used in document's head
description = "Nice theme for homepages and blogs"
keywords = ""
images = [""]
homeSubtitle = "Hello Friend NG"
# Prefix of link to the git commit detail page. GitInfo must be enabled.
# gitUrl = ""
# Integrate Javascript files or stylesheets by adding the url to the external assets or by
# linking local files with their path relative to the static folder, e.g. "css/styles.css"
customCSS = []
customJS = []
# Toggle this option need to rebuild SCSS, requires extended version of Hugo
justifyContent = false # Set "text-align: justify" to .content.
# Directory name of your blog content (default is `content/posts`)
contentTypeName = "posts"
# Default theme "light" or "dark"
defaultTheme = "dark"
themeColor = "#252627"
[params.logo]
logoText = "$ cd /home/"
logoHomeLink = "/"
# Social icons
[[params.social]]
name = "twitter"
url = "https://twitter.com/"
[[params.social]]
name = "email"
url = "mailto:nobody@example.com"
[[params.social]]
name = "github"
url = "https://github.com/"
[[params.social]]
name = "linkedin"
url = "https://www.linkedin.com/"
[languages]
[languages.en]
subtitle = "Hello Friend NG Theme"
weight = 1
copyright = '<a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noopener">CC BY-NC 4.0</a>'
[languages.fr]
subtitle = "Hello Friend NG Theme"
weight = 2
copyright = '<a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noopener">CC BY-NC 4.0</a>'
[menu]
[[menu.main]]
identifier = "about"
name = "About"
url = "about/"
[[menu.main]]
identifier = "posts"
name = "Posts"
url = "posts/"

View file

@ -0,0 +1,19 @@
+++
title = "About"
date = "2014-04-09"
aliases = ["about-us","about-hugo","contact"]
[ author ]
name = "Hugo Authors"
+++
Hugo is the **worlds fastest framework for building websites**. It is written in Go.
It makes use of a variety of open source projects including:
* https://github.com/russross/blackfriday
* https://github.com/alecthomas/chroma
* https://github.com/muesli/smartcrop
* https://github.com/spf13/cobra
* https://github.com/spf13/viper
Learn more and contribute on [GitHub](https://github.com/gohugoio).

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,352 @@
+++
categories = ["Go"]
date = "2014-04-02"
description = ""
featured = "pic02.jpg"
featuredalt = ""
featuredpath = "date"
linktitle = ""
slug = "Introduction aux modeles Hugo"
title = "Introduction aux modèles (Hu)go"
type = ["posts","post"]
[ author ]
name = "Michael Henderson"
+++
Hugo utilise l'excellente librairie [go][] [html/template][gohtmltemplate] pour
son moteur de modèles. c'est un moteur extrêmement léger qui offre un très petit
nombre de fonctions logiques. À notre expérience, c'est juste ce qu'il faut pour
créer un bon site web statique. Si vous avez déjà utilisé d'autre moteurs de
modèles pour différents langages ou frameworks, vous allez retrouver beaucoup de
similitudes avec les modèles go.
Ce document est une introduction sur l'utilisation de Go templates. La
[documentation go][gohtmltemplate] fourni plus de détails.
## Introduction aux modèles Go
Go templates fournit un langage de modèles très simple. Il adhère à la
conviction que les modèles ou les vues doivent avoir une logique des plus
élémentaires. L'une des conséquences de cette simplicité est que les modèles
seront plus rapides a être analysés.
Une caractéristique unique de Go templates est qu'il est conscient du contenu.
Les variables et le contenu va être nettoyé suivant le contexte d'utilisation.
Plus de détails sont disponibles dans la [documentation go][gohtmltemplate].
## Syntaxe basique
Les modèles en langage Go sont des fichiers HTML avec l'ajout de variables et
fonctions.
**Les variables Go et les fonctions sont accessibles avec {{ }}**
Accès à une variable prédéfinie "foo":
{{ foo }}
**Les paramètres sont séparés par des espaces**
Appel de la fonction add avec 1 et 2 en argument**
{{ add 1 2 }}
**Les méthodes et les champs sont accessibles par un point**
Accès au paramètre de la page "bar"
{{ .Params.bar }}
**Les parenthèses peuvent être utilisées pour grouper des éléments ensemble**
```
{{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
```
## Variables
Chaque modèle go a une structure (objet) mis à sa disposition. Avec Hugo, à
chaque modèle est passé soit une page, soit une structure de nœud, suivant quel
type de page vous rendez. Plus de détails sont disponibles sur la page des
[variables](/layout/variables).
Une variable est accessible par son nom.
<title>{{ .Title }}</title>
Les variables peuvent également être définies et appelées.
{{ $address := "123 Main St."}}
{{ $address }}
## Functions
Go templace est livré avec quelques fonctions qui fournissent des
fonctionnalités basiques. Le système de Go template fourni également un
mécanisme permettant aux applications d'étendre les fonctions disponible. Les
[fonctions de modèle Hugo](/layout/functions) fourni quelques fonctionnalités
supplémentaires que nous espérons qu'elles seront utiles pour vos sites web.
Les functions sont appelées en utilisant leur nom suivi par les paramètres
requis séparés par des espaces. Des fonctions de modèles ne peuvent pas être
ajoutées sans recompiler Hugo.
**Exemple:**
{{ add 1 2 }}
## Inclusions
Lorsque vous incluez un autre modèle, vous devez y passer les données qu'il sera
en mesure d'accèder. Pour passer le contexte actuel, pensez à ajouter un point.
La localisation du modèle sera toujours à partir du répertoire /layout/ dans
Hugo.
**Exemple:**
{{ template "chrome/header.html" . }}
## Logique
Go templates fourni les itérations et la logique conditionnèle des plus basique.
### Itération
Comme en go, les modèles go utilisent fortement *range* pour itérer dans une
map, un array ou un slice. Les exemples suivant montre différentes façons
d'utiliser *range*
**Exemple 1: En utilisant le context**
{{ range array }}
{{ . }}
{{ end }}
**Exemple 2: En déclarant un nom de variable**
{{range $element := array}}
{{ $element }}
{{ end }}
**Exemple 2: En déclarant un nom de varialbe pour la clé et la valeur**
{{range $index, $element := array}}
{{ $index }}
{{ $element }}
{{ end }}
### Conditions
*If*, *else*, *with*, *or*, *&*, *and* fournissent la base pour la logique
conditionnelle avec Go templates. Comme *range*, chaque déclaration est fermé
avec `end`.
Go templates considère les valeurs suivante comme *false* :
* false
* 0
* tout array, slice, map ou chaine d'une longueur de zéro
**Exemple 1: If**
{{ if isset .Params "title" }}<h4>{{ index .Params "title" }}</h4>{{ end }}
**Exemple 2: If -> Else**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{else}}
{{ index .Params "caption" }}
{{ end }}
**Exemple 3: And & Or**
```
{{ if and (or (isset .Params "title") (isset .Params "caption"))
(isset .Params "attr")}}
```
**Exemple 4: With**
Une manière alternative d'écrire un "if" et de référencer cette même valeur est
d'utiliser "with". Cela permet de remplacer le contexte `.` par cet valeur et
saute le bloc si la variable est absente.
Le premier exemple peut être simplifié à ceci :
{{ with .Params.title }}<h4>{{ . }}</h4>{{ end }}
**Exemple 5: If -> Else If**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{ else if isset .Params "caption" }}
{{ index .Params "caption" }}
{{ end }}
## *Pipes*
L'un des composants le plus puissant de Go templates est la capacité d'empiler
les action l'une après l'autre. Cela est fait en utilisant les *pipes*.
Empruntés aux *pipes* unix, le concept est simple. Chaque sortie de *pipeline*
devient l'entrée du *pipe* suivant.
À cause de la syntaxe très simple de Go templates, le *pipe* est essentiel pour
être capable d'enchainer les appels de fonctions. Une limitation des *pipes*
est qu'il ne peuvent fonctionner seulement avec une seule valeur et cette valeur
devient le dernier paramètre du prochain *pipeline*.
Quelques exemples simple devrait vous aider à comprendre comment utiliser les
*pipes*.
**Exemple 1 :**
{{ if eq 1 1 }} Same {{ end }}
est identique à
{{ eq 1 1 | if }} Same {{ end }}
Il semble étrange de placer le *if* à la fin, mais il fournit une bonne
illustration de la façon d'utiliser les tuyaux.
**Exemple 2 :**
{{ index .Params "disqus_url" | html }}
Accès au paramètre de page nommé "disqus_url" et échappement du HTML
**Exemple 3 :**
```
{{ if or (or (isset .Params "title") (isset .Params "caption"))
(isset .Params "attr")}}
Stuff Here
{{ end }}
```
Peut être réécrit en
```
{{ isset .Params "caption" | or isset .Params "title" |
or isset .Params "attr" | if }}
Stuff Here
{{ end }}
```
## Contexte (alias. le point)
Le concept le plus facilement négligé pour comprendre les modèles go est que
{{ . }} fait toujours référence au contexte actuel. Dans le plus haut niveau de
votre modèle, ce sera l'ensemble des données mis à votre disposition. Dans une
itération, ce sera la valeur de l'élément actuel. Enfin, dans une boucle, le
contexte change. . ne fera plus référence aux données disponibles dans la page
entière. Si vous avez besoin y d'accèder depuis l'intérieur d'une boucle, il est
judicieux d'y définir comme variable au lieu de dépendre du contexte.
**Exemple:**
```
{{ $title := .Site.Title }}
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">
{{ . }}</a> - {{ $title }} </li>
{{ end }}
```
Notez que, une fois que nous sommes entrés dans la boucle, la valeur de
{{ . }} a changée. Nous avons défini une variable en dehors de la boucle, afin
d'y avoir accès dans la boucle.
# Les Paramètres d'Hugo
Hugo fournit l'option de passer des valeurs au modèle depuis la configuration du
site, ou depuis les métadonnées de chaque partie du contenu. Vous pouvez définir
n'importe quelle valeur de n'importe quel type (supporté par votre section
liminaire / format de configuration) et les utiliser comme vous le souhaitez
dans votre modèle.
## Utiliser les paramètres de contenu (page)
Dans chaque partie du contenu, vous pouvez fournir des variables pour être
utilisées par le modèle. Cela se passe dans la
[section liminaire](/content/front-matter).
Un exemple de cela est utilisé par ce site de documentation. La plupart des
pages bénéficient de la présentation de la table des matières. Quelques fois,
la table des matières n'a pas beaucoup de sens. Nous avons défini une variable
dans notre section liminaire de quelques pages pour désactiver la table des
matières.
Ceci est un exemple de section liminaire :
```
---
title: "Permalinks"
date: "2013-11-18"
aliases:
- "/doc/permalinks/"
groups: ["extras"]
groups_weight: 30
notoc: true
---
```
Ceci est le code correspondant dans le modèle :
{{ if not .Params.notoc }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
{{ end }}
## Utiliser les paramètres de site (config)
Dans votre configuration de plus haut niveau (ex `config.yaml`), vous pouvez
définir des paramètres de site, dont les valeurs vous seront accessibles.
Pour les instances, vous pourriez délarer :
```yaml
params:
CopyrightHTML: "Copyright &#xA9; 2013 John Doe. All Rights Reserved."
TwitterUser: "spf13"
SidebarRecentLimit: 5
```
Avec un pied de page, vous devriez déclarer un `<footer>` qui est affiché
seulement si le paramètre `CopyrightHTML` est déclaré, et si il l'est, vous
devriez le déclarer comme HTML-safe, afin d'éviter d'échapper les entités HTML.
Cela vous permettra de le modifier facilement dans votre configuration au lieu
de le chercher dans votre modèle.
```
{{if .Site.Params.CopyrightHTML}}<footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
</footer>{{end}}
```
Une alternative au "if" et d'appeler la même valeur est d'utiliser "with". Cela
modifiera le contexte et passera le bloc si la variable est absente :
```
{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
alt="Twitter"></a>
</span>{{end}}
```
Enfin, si vous souhaitez extraire des "constantes magiques" de vos mises en
page, vous pouvez le faire comme dans l'exemple suivant :
```
<nav class="recent">
<h1>Recent Posts</h1>
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
{{end}}</ul>
</nav>
```
[go]: <http://golang.org/>
[gohtmltemplate]: <http://golang.org/pkg/html/template/>

View file

@ -0,0 +1,347 @@
+++
title = "(Hu)go Template Primer"
description = ""
type = ["posts","post"]
tags = [
"go",
"golang",
"templates",
"themes",
"development",
]
date = "2014-04-02"
categories = [
"Development",
"golang",
]
series = ["Hugo 101"]
[ author ]
name = "Hugo Authors"
+++
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
Golang 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>{{ .Title }}</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" }}<h4>{{ index .Params "title" }}</h4>{{ 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 }}<h4>{{ . }}</h4>{{ 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 }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li>
{{ 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 }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
{{ 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 &#xA9; 2013 John Doe. All Rights Reserved."
TwitterUser: "spf13"
SidebarRecentLimit: 5
```
Within a footer layout, you might then declare a `<footer>` which is only
provided if the `CopyrightHTML` parameter is provided, and if it is given,
you would declare it to be HTML-safe, so that the HTML entity is not escaped
again. This would let you easily update just your top-level config file each
January 1st, instead of hunting through your templates.
```
{{if .Site.Params.CopyrightHTML}}<footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
</footer>{{end}}
```
An alternative way of writing the "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:
```
{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
alt="Twitter"></a>
</span>{{end}}
```
Finally, if you want to pull "magic constants" out of your layouts, you can do
so, such as in this example:
```
<nav class="recent">
<h1>Recent Posts</h1>
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
{{end}}</ul>
</nav>
```
[go]: https://golang.org/
[gohtmltemplate]: https://golang.org/pkg/html/template/

View file

@ -0,0 +1,99 @@
+++
categories = ["Hugo"]
date = "2014-04-02"
description = ""
featured = "pic03.jpg"
featuredalt = "Pic 3"
featuredpath = "date"
linktitle = ""
slug = "Debuter avec Hugo"
title = "Débuter avec Hugo"
type = "post"
[ author ]
name = "Hugo Authors"
+++
## Étape 1. Installer Hugo
Allez sur la page de téléchargements de
[hugo](https://github.com/spf13/hugo/releases) et téléchargez la version
appropriée à votre système d'exploitation et votre architecture.
Sauvegardez le fichier téléchargé à un endroit précis, afin de l'utiliser dans
l'étape suivante.
Des informations plus complètes sont disponibles sur la page
[installing hugo](/overview/installing/)
<!--more-->
## Étape 2. Compilez la documentation
Hugo possède son propre site d'exemple qui se trouve être également le site que
vous lisez actuellement.
Suivez les instructions suivante :
1. Clonez le [dépôt de hugo](http://github.com/spf13/hugo)
2. Allez dans ce dépôt
3. Lancez Hugo en mode serveur et compilez la documentation
4. Ouvrez votre navigateur sur http://localhost:1313
Voici les commandes génériques correspondantes :
git clone https://github.com/spf13/hugo
cd hugo
/chemin/ou/vous/avez/installe/hugo server --source=./docs
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Press ctrl+c to stop
Lorsque vous avez cela, continuez le reste de ce guide sur votre version locale.
## Étape 3. Changer le site de documentation
Arrêtez le processus de Hugo en pressant ctrl+c.
Maintenant, nous allons relancer hugo, mais cette fois avec Hugo en mode de
surveillance.
/chemin/vers/hugo/de/l-etape/1/hugo server --source=./docs --watch
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Watching for changes in /Users/spf13/Code/hugo/docs/content
> Press ctrl+c to stop
Ouvrez votre [éditeur favori](https://vim.spf13.com) et changer l'une des
sources des pages de contenu.
Open your [favorite editor](http://vim.spf13.com) and change one of the source
content pages. Que diriez-vous de modifier ce fichier pour *résoudre une faute
de typo*.
Les fichiers de contenu peuvent être trouvés dans `docs/content/`. Sauf
indication contraire, les fichiers sont situés au même emplacement relatif que
l'URL, dans notre cas `docs/content/overview/quickstart.md`.
Modifiez et sauvegardez ce fichier. Notez ce qu'il se passe dans le terminal.
> Change detected, rebuilding site
> 29 pages created
> 0 tags index created
> in 26 ms
Rechargez la page dans votre navigateur et voyez que le problème de typo est
maintenant résolu.
Notez à quel point cela a été rapide. Essayez de recharger le site avant qu'il
soit fini de compiler.
Notice how quick that was. Try to refresh the site before it's finished
building. Je paris que vous n'y arrivez pas.
Le fait d'avoir des réactions presque instantanées vous permet d'avoir votre
créativité fluide sans avoir à attendre de longues compilations.
## Step 4. Amusez-vous
Le meilleur moyen d'apprendre quelque chose est de s'amuser avec.

View file

@ -0,0 +1,92 @@
+++
title = "Getting Started with Hugo"
description = ""
type = ["posts","post"]
tags = [
"go",
"golang",
"hugo",
"development",
]
date = "2014-04-02"
categories = [
"Development",
"golang",
]
series = ["Hugo 101"]
[ author ]
name = "Hugo Authors"
+++
## Step 1. Install Hugo
Go to [Hugo releases](https://github.com/spf13/hugo/releases) and download the
appropriate version for your OS and architecture.
Save it somewhere specific as we will be using it in the next step.
More complete instructions are available at [Install Hugo](https://gohugo.io/getting-started/installing/)
## Step 2. Build the Docs
Hugo has its own example site which happens to also be the documentation site
you are reading right now.
Follow the following steps:
1. Clone the [Hugo repository](http://github.com/spf13/hugo)
2. Go into the repo
3. Run hugo in server mode and build the docs
4. Open your browser to http://localhost:1313
Corresponding pseudo commands:
git clone https://github.com/spf13/hugo
cd hugo
/path/to/where/you/installed/hugo server --source=./docs
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Press ctrl+c to stop
Once you've gotten here, follow along the rest of this page on your local build.
## Step 3. Change the docs site
Stop the Hugo process by hitting Ctrl+C.
Now we are going to run hugo again, but this time with hugo in watch mode.
/path/to/hugo/from/step/1/hugo server --source=./docs --watch
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Watching for changes in /Users/spf13/Code/hugo/docs/content
> Press ctrl+c to stop
Open your [favorite editor](http://vim.spf13.com) and change one of the source
content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
Content files are found in `docs/content/`. Unless otherwise specified, files
are located at the same relative location as the url, in our case
`docs/content/overview/quickstart.md`.
Change and save this file.. Notice what happened in your terminal.
> Change detected, rebuilding site
> 29 pages created
> 0 tags index created
> in 26 ms
Refresh the browser and observe that the typo is now fixed.
Notice how quick that was. Try to refresh the site before it's finished building. I double dare you.
Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
## Step 4. Have fun
The best way to learn something is to play with it.

View file

@ -0,0 +1,218 @@
+++
categories = ["Hugo", "Jekyll"]
date = "2014-03-10"
description = ""
featured = ""
featuredalt = ""
featuredpath = ""
linktitle = ""
slug = "Migrer vers Hugo depuis Jekyll"
title = "Migrer vers Hugo depuis Jekyll"
type = ["posts","post"]
[ author ]
name = "Hugo Authors"
+++
## Déplacez le contenu statique vers `static`
Jekyll a une règle comme quoi tout répertoire qui ne commence pas par `_` sera
copié tel-quel dans le répertoire `_site`. Hugo garde tout le contenu statique
dans le répertoire `static`. Vous devez donc déplacer tout ce type de contenu
là-dedans. Avec Jekylll, l'arborescence ressemblant à ceci :
<root>/
▾ images/
logo.png
<!--more-->
doit devenir
<root>/
▾ static/
▾ images/
logo.png
En outre, vous allez devoir déplacer tous les fichiers présents à la racine vers
le répertoire `static`.
## Créez votre configuration Hugo
Hugo peut lire votre fichier de configuration au format JSON, YAML et TOML. Hugo
supporte également les paramètres de configuration. Plus d'informations sur la
[documentation de configuration Hugo](/overview/configuration/)
## Définiez votre répertoire de publication sur `_site`
La valeur par défaut pour Jekyll est d'utiliser le répertoire `_site` pour
publier le contenu. Pour Hugo, le répertoire de publication est `public`. Si,
comme moi, vous avez [lié `_site` vers un sous-module git sur la branche
`gh-pages`](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.ht
ml), vous allez vouloir avoir quelques alternatives :
1. Changez votre lien du sous-module `gh-pages` pour pointer sur public au lieu
de `_site` (recommendé).
git submodule deinit _site
git rm _site
git submodule add -b gh-pages
git@github.com:your-username/your-repo.git public
2. Ou modifiez la configuration de Hugo pour utiliser le répertoire `_site` au
lieu de `public`.
{
..
"publishdir": "_site",
..
}
## Convertir un thème Jekyll pour Hugo
C'est la majeure partie du travail. La documentation est votre ami.
Vous devriez vous référer à [la documentation des thèmes de Jekyll]
(http://jekyllrb.com/docs/templates/) si vous devez vous rafraîchir la mémoire
sur la façon dont vous avez construit votre blog et [les thèmes de Hugo]
(/layout/templates/) pour apprendre la manière de faire sur Hugo.
Pour vous donner un point de référence, la conversion du thème pour
[heyitsalex.net](http://heyitsalex.net/) ne m'a pris que quelques heures.
## Convertir les extensions Jekyll vers des shortcodes Hugo
Jekyll support les [extensions](http://jekyllrb.com/docs/plugins/); Hugo lui a
les [shortcodes](/doc/shortcodes/). C'est assez banal les porter.
### Implémentation
Comme exemple, j'utilise une extension pour avoir un [`image_tag`](https://githu
b.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc
06908ec/_plugins/image_tag.rb) presonnalisé pour générer les images avec une
légende sur Jekyll. J'ai vu que Hugo implémente un shortcode qui fait exactement
la même chose.
Extension Jekyll :
```
module Jekyll
class ImageTag < Liquid::Tag
@url = nil
@caption = nil
@class = nil
@link = nil
// Patterns
IMAGE_URL_WITH_CLASS_AND_CAPTION =
IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK =
/(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->
((https?:\/\/|\/)(\S+))(\s*)/i
IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
def initialize(tag_name, markup, tokens)
super
if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
@class = $1
@url = $3
@caption = $7
@link = $9
elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
@class = $1
@url = $3
@caption = $7
elsif markup =~ IMAGE_URL_WITH_CAPTION
@url = $1
@caption = $5
elsif markup =~ IMAGE_URL_WITH_CLASS
@class = $1
@url = $3
elsif markup =~ IMAGE_URL
@url = $1
end
end
def render(context)
if @class
source = "<figure class='#{@class}'>"
else
source = "<figure>"
end
if @link
source += "<a href=\"#{@link}\">"
end
source += "<img src=\"#{@url}\">"
if @link
source += "</a>"
end
source += "<figcaption>#{@caption}</figcaption>" if @caption
source += "</figure>"
source
end
end
end
Liquid::Template.register_tag('image', Jekyll::ImageTag)
```
Écrite en tant que shortcode Hugo:
```
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}"
{{ if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt"}}
{{.}}
{{else}}
{{ .Get "caption" }}
{{ end }}"
{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
{{ .Get "title" }}{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->
```
### Utilisation
J'ai simplement changé :
```
{% image
full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg
"One of my favorite touristy-type photos. I secretly waited for the
good light while we were "having fun" and took this. Only regret: a
stupid pole in the top-left corner of the frame I had to clumsily get
rid of at post-processing."
->http://www.flickr.com/photos/alexnormand/4829260124/in/
set-72157624547713078/ %}
```
pour cela (cet exemple utilise une version légèrement étendue nommée `fig`,
différente de la `figure` intégrée) :
```
{{%/* fig class="full"
src="http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg"
title="One of my favorite touristy-type photos. I secretly waited for the
good light while we were having fun and took this. Only regret: a stupid
pole in the top-left corner of the frame I had to clumsily get rid of at
post-processing."
link="http://www.flickr.com/photos/alexnormand/4829260124/in/
set-72157624547713078/" */%}}
```
Comme bonus, les paramètres nommés des shortcodes sont plus lisibles.
## Touches finales
### Corriger le contenu
Suivant le nombre de modifications que vous avez effectué sur chaque articles
avec Jekyll, cette étape requierra plus ou moins d'efforts. Il n'y a pas de
règles rigoureuses ici, si ce n'est que `hugo server --watch` est votre ami.
Testez vos modifications et corrigez les erreurs au besoin.
### Nettoyez le tout
Vous voudrez sûrement supprimer votre configuration Jekyll maintenant que tout
est fini. Exact, pensez à supprimer tout ce qui est inutilisé.
## Un exemple pratique
[Hey, it's Alex](http://heyitsalex.net/) a été migré de Jekyll vers Hugo en
moins de temps qu'une journée père enfant. Vous pouvez trouver toutes les
modification en regardant ce [diff](https://github.com/alexandre-normand/alexand
re-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b
81495423294208cc74d610).

View file

@ -0,0 +1,161 @@
---
author:
name: "Hugo Authors"
date: 2014-03-10
linktitle: Migrating from Jekyll
title: Migrate to Hugo from Jekyll
type:
- post
- posts
weight: 10
series:
- Hugo 101
aliases:
- /blog/migrate-from-jekyll/
---
## Move static content to `static`
Jekyll has a rule that any directory not starting with `_` will be copied as-is to the `_site` output. Hugo keeps all static content under `static`. You should therefore move it all there.
With Jekyll, something that looked like
<root>/
▾ images/
logo.png
should become
<root>/
▾ static/
▾ images/
logo.png
Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
## Create your Hugo configuration file
Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the [Hugo configuration documentation](/overview/configuration/) for details.
## Set your configuration publish folder to `_site`
The default is for Jekyll to publish to `_site` and for Hugo to publish to `public`. If, like me, you have [`_site` mapped to a git submodule on the `gh-pages` branch](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html), you'll want to do one of two alternatives:
1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
git submodule deinit _site
git rm _site
git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
2. Or, change the Hugo configuration to use `_site` instead of `public`.
{
..
"publishdir": "_site",
..
}
## Convert Jekyll templates to Hugo templates
That's the bulk of the work right here. The documentation is your friend. You should refer to [Jekyll's template documentation](http://jekyllrb.com/docs/templates/) if you need to refresh your memory on how you built your blog and [Hugo's template](/layout/templates/) to learn Hugo's way.
As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
## Convert Jekyll plugins to Hugo shortcodes
Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
### Implementation
As an example, I was using a custom [`image_tag`](https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb) plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.
Jekyll's plugin:
module Jekyll
class ImageTag < Liquid::Tag
@url = nil
@caption = nil
@class = nil
@link = nil
// Patterns
IMAGE_URL_WITH_CLASS_AND_CAPTION =
IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
def initialize(tag_name, markup, tokens)
super
if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
@class = $1
@url = $3
@caption = $7
@link = $9
elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
@class = $1
@url = $3
@caption = $7
elsif markup =~ IMAGE_URL_WITH_CAPTION
@url = $1
@caption = $5
elsif markup =~ IMAGE_URL_WITH_CLASS
@class = $1
@url = $3
elsif markup =~ IMAGE_URL
@url = $1
end
end
def render(context)
if @class
source = "<figure class='#{@class}'>"
else
source = "<figure>"
end
if @link
source += "<a href=\"#{@link}\">"
end
source += "<img src=\"#{@url}\">"
if @link
source += "</a>"
end
source += "<figcaption>#{@caption}</figcaption>" if @caption
source += "</figure>"
source
end
end
end
Liquid::Template.register_tag('image', Jekyll::ImageTag)
is written as this Hugo shortcode:
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
{{ .Get "title" }}{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->
### Usage
I simply changed:
{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "One of my favorite touristy-type photos. I secretly waited for the good light while we were "having fun" and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`):
{{%/* fig class="full" src="http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg" title="One of my favorite touristy-type photos. I secretly waited for the good light while we were having fun and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." link="http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/" */%}}
As a bonus, the shortcode named parameters are, arguably, more readable.
## Finishing touches
### Fix content
Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that `hugo server --watch` is your friend. Test your changes and fix errors as needed.
### Clean up
You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
## A practical example in a diff
[Hey, it's Alex](http://heyitsalex.net/) was migrated in less than a _father-with-kids day_ from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this [diff](https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610).

36
i18n/de.toml Normal file
View file

@ -0,0 +1,36 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Übersetzungen"
[postAvailable]
other = "Auch verfügbar auf"
# 404.html
#
[archives]
other = "Archiv"
[home]
other = "Home"
[notFound]
other = "Oops, Seite nicht gefunden ..."
# posts/single.html
#
[readingTime]
one = "Eine Minute"
other = "{{ .Count }} Minuten"
[tableOfContents]
other = "Inhaltsverzeichnis"
[wordCount]
one = "Ein Wort"
other = "{{ .Count }} Wörter"

36
i18n/en.toml Normal file
View file

@ -0,0 +1,36 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Translations"
[postAvailable]
other = "Also available in"
# 404.html
#
[archives]
other = "Archives"
[home]
other = "Home"
[notFound]
other = "Oops, page not found…"
# posts/single.html
#
[readingTime]
one = "One minute"
other = "{{ .Count }} minutes"
[tableOfContents]
other = "Table of Contents"
[wordCount]
one = "One Word"
other = "{{ .Count }} Words"

36
i18n/es.toml Normal file
View file

@ -0,0 +1,36 @@
# Translations for Spanish
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traducciones"
[postAvailable]
other = "También disponible en"
# 404.html
#
[archives]
other = "Archivo"
[home]
other = "Home"
[notFound]
other = "Oops, página no encontrada…"
# posts/single.html
#
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minutos"
[tableOfContents]
other = "Tabla de Contenido"
[wordCount]
one = "Una Palabra"
other = "{{ .Count }} Palabras"

36
i18n/fr.toml Normal file
View file

@ -0,0 +1,36 @@
# Translations for France
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traductions"
[postAvailable]
other = "Aussi disponible en"
# 404.html
#
[archives]
other = "Les archives"
[home]
other = "Accueil"
[notFound]
other = "Oups, page non trouvée …"
# posts/single.html
#
[readingTime]
one = "Une minute"
other = "{{ .Count }} minutes"
[tableOfContents]
other = "Table des matières"
[wordCount]
one = "Un Mot"
other = "{{ .Count }} Mots"

36
i18n/pt-br.toml Normal file
View file

@ -0,0 +1,36 @@
# Translations for Portuguese
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traduções"
[postAvailable]
other = "Também disponível em"
# 404.html
#
[archives]
other = "Arquivo"
[home]
other = "Início"
[notFound]
other = "Oops, página não encontrada…"
# posts/single.html
#
[readingTime]
one = "Um minuto"
other = "{{ .Count }} minutos"
[tableOfContents]
other = "Índice"
[wordCount]
one = "Uma Palavra"
other = "{{ .Count }} Palavras"

BIN
images/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
images/tn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

15
layouts/404.html Normal file
View file

@ -0,0 +1,15 @@
{{ define "main" }}
<div id="spotlight" class="error-404 animated fadeIn">
<p class="img-404">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-cloud-drizzle"><line x1="8" y1="19" x2="8" y2="21"></line><line x1="8" y1="13" x2="8" y2="15"></line><line x1="16" y1="19" x2="16" y2="21"></line><line x1="16" y1="13" x2="16" y2="15"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="12" y1="15" x2="12" y2="17"></line><path d="M20 16.58A5 5 0 0 0 18 7h-1.26A8 8 0 1 0 4 15.25"></path></svg>
</p>
<div class="banner-404">
<h1>404</h1>
<p>{{ i18n "notFound" }}</p>
<p class="btn-404">
<a href="{{.Site.BaseURL}}"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>{{ i18n "home" }}</a>
<a href="{{ "posts" | absLangURL }}"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-archive"><polyline points="21 8 21 21 3 21 3 8"></polyline><rect x="1" y="3" width="22" height="5"></rect><line x1="10" y1="12" x2="14" y2="12"></line></svg>{{ i18n "archives" }}</a>
</p>
</div>
</div>
{{ end }}

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="{{ .Site.Language }}">
<head>
{{ partial "head.html" . }}
</head>
<body class="{{ if ne $.Site.Params.defaultTheme "light" -}} dark-theme {{- end -}}">
<div class="container">
{{ partial "header.html" . }}
<div class="content">
{{ block "main" . }}{{ end }}
</div>
{{ block "footer" . }}
{{ partial "footer.html" . }}
{{ end }}
</div>
{{ partial "javascript.html" . }}
</body>
</html>

View file

@ -0,0 +1,26 @@
{{ define "main" }}
<main class="posts">
<h1>{{ .Title }}</h1>
{{- if .Content }}
<div class="content">{{ .Content }}</div>
{{- end }}
{{- range .Data.Pages.GroupByDate "2006" }}
<div class="posts-group">
<div class="post-year">{{ .Key }}</div>
<ul class="posts-list">
{{- range .Pages }}
<li class="post-item">
<a href="{{.Permalink}}">
<span class="post-title">{{.Title}}</span>
<span class="post-day">{{ if .Site.Params.dateformShort }}{{ .Date.Format .Site.Params.dateformShort }}{{ else }}{{ .Date.Format "Jan 2"}}{{ end }}</span>
</a>
</li>
{{- end }}
</ul>
</div>
{{- end }}
</main>
{{ end }}

View file

@ -0,0 +1,58 @@
{{ define "main" }}
<main class="post">
<div class="post-info">
{{ if .IsTranslated }}
{{ i18n "postAvailable" }}
{{ range .Translations }}
<a href="{{ .Permalink }}"><span class="flag flag-icon flag-icon-{{ index $.Site.Data.langFlags (.Lang) }} flag-icon-squared"></span></a>
{{ end}}
{{ end }}
</p>
</div>
<article>
<h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
{{- if .Params.toc }}
<hr />
<aside id="toc">
<div class="toc-title">{{ i18n "tableOfContents" }}</div>
{{ .TableOfContents }}
</aside>
<hr />
{{- end }}
{{ with .Params.Cover }}
<img src="/img/{{ . }}" class="post-cover" />
{{ end }}
<div class="post-content">
{{ .Content }}
</div>
</article>
<hr />
<div class="post-info">
{{- with .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- range . -}}
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }}
</p>
{{- end }}
{{- if .GitInfo }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit"><circle cx="12" cy="12" r="4"></circle><line x1="1.05" y1="12" x2="7" y2="12"></line><line x1="17.01" y1="12" x2="22.96" y2="12"></line></svg><a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash }}</a> @ {{ if .Site.Params.dateformNum }}{{ dateFormat .Site.Params.dateformNum .GitInfo.AuthorDate.Local }}{{ else }}{{ dateFormat "2006-01-02" .GitInfo.AuthorDate.Local }}{{ end }}</p>
{{- end }}
</div>
{{ if .Params.comments }}
<div id="comments" class="thin">
{{- partial "comments.html" . -}}
</div>
{{ end }}
</main>
{{ end }}

17
layouts/index.html Normal file
View file

@ -0,0 +1,17 @@
{{ define "main" }}
<main aria-role="main">
<div>
<h1>{{ .Site.Title }}</h1>
{{- with .Site.Params.homeSubtitle }}
<p>{{.}}</p>
{{- end }}
{{- with .Site.Params.social }}
<div>
{{ partial "social-icons.html" . }}
</div>
{{- end }}
</div>
</main>
{{ end }}

View file

@ -0,0 +1,3 @@
{{- if .Site.DisqusShortname }}
{{ template "_internal/disqus.html" . }}
{{- end }}

View file

@ -0,0 +1,7 @@
<link rel="apple-touch-icon" sizes="180x180" href="{{"apple-touch-icon.png" | relURL}}">
<link rel="icon" type="image/png" sizes="32x32" href="{{"favicon-32x32.png" | relURL}}">
<link rel="icon" type="image/png" sizes="16x16" href="{{"favicon-16x16.png" | relURL}}">
<link rel="manifest" href="{{"site.webmanifest" | relURL}}">
<link rel="mask-icon" href="{{"safari-pinned-tab.svg" | relURL}}" color="#252627">
<link rel="shortcut icon" href="{{"favicon.ico" | relURL}}">
<meta name="theme-color" content="#252627">

View file

@ -0,0 +1,23 @@
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; {{ now.Format "2006" }}</span>
{{ if .Site.Author.name }}
<span><a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a></span>
{{ end }}
<span>{{ .Site.Copyright| safeHTML }}</span>
<span>{{- with (not (in (.Site.Language.Get "disableKinds") "RSS")) }} <a href="{{ "posts/index.xml" | absLangURL }}" target="_blank" title="rss"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"><path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle></svg></a>{{ end }}</span>
</div>
</div>
<div class="footer__inner">
<div class="footer__content">
</div>
</div>
<div class="footer__inner">
<div class="footer__content">
<span>Powered by <a href="http://gohugo.io">Hugo</a></span>
<span>Made with &#10084; by <a href="https://github.com/rhazdon">rhazdon</a></span>
</div>
</div>
</footer>

View file

@ -0,0 +1,61 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author"
content="{{ if .Params.author }}{{ .Params.author }}{{ else }}{{ range .Site.Author }}{{ . }} {{ end }}{{ end }}">
<meta name="description"
content="{{ if .IsHome }}{{ .Site.Params.homeSubtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}" />
<meta name="keywords" content="{{ .Site.Params.keywords }}" />
<meta name="robots" content="noodp" />
<link rel="canonical" href="{{ .Permalink }}" />
{{ block "title" . }}
<title>
{{ if .IsHome }}
{{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }} {{ end }}
{{ else }}
{{ .Title }} :: {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }}{{ end }}
{{ end }}
</title>
{{ end }}
<!-- CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.2.1/css/flag-icon.min.css" rel="stylesheet"
type="text/css">
{{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $style := resources.Get "scss/main.scss" | resources.ToCSS $options | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{ range $val := $.Site.Params.customCSS }}
{{ if gt (len $val) 0 }}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
{{ end }}
<!-- Icons -->
{{- partial "favicons.html" }}
{{- template "_internal/schema.html" . }}
{{- template "_internal/twitter_cards.html" . }}
{{ range .Params.categories }}
<meta property="article:section" content="{{ . }}" />{{ end }}
{{ if isset .Params "date" }}
<meta property="article:published_time" content="{{ time .Date }}" />{{ end }}
<!-- RSS -->
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<!-- JSON Feed -->
{{ if .OutputFormats.Get "json" }}
<link href="{{ if .OutputFormats.Get "json" }}{{ .Site.BaseURL }}feed.json{{ end }}" rel="alternate"
type="application/json" title="{{ .Site.Title }}" />
{{ end }}
<!-- Custom head tags -->
{{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }}
{{- end }}

View file

@ -0,0 +1,19 @@
<header class="header">
<span class="header__inner">
{{ partial "logo.html" . }}
<span class="header__right">
{{ if len .Site.Menus }}
{{ partial "menu.html" . }}
<span class="menu-trigger">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
</svg>
</span>
{{ end }}
<span class="theme-toggle">{{ partial "theme-icon.html" . }}</span>
</span>
</span>
</header>

View file

@ -0,0 +1,23 @@
{{ $main := resources.Get "js/main.js" }}
{{ $menu := resources.Get "js/menu.js" }}
{{ $prism := resources.Get "js/prism.js" }}
{{ $theme := resources.Get "js/theme.js" }}
{{ $secureJS := slice $main $menu $prism $theme | resources.Concat "bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
<script type="text/javascript" src="{{ $secureJS.RelPermalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{- if .Site.GoogleAnalytics }}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{.Site.GoogleAnalytics}}', 'auto');
ga('send', 'pageview');
</script>
{{- end}}
{{ range $val := $.Site.Params.customJS }}
{{ if gt (len $val) 0 }}
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}

View file

@ -0,0 +1,11 @@
<a href="{{ if .Site.Params.Logo.LogoHomeLink }}{{ .Site.Params.Logo.LogoHomeLink }}{{else}}{{ .Site.BaseURL }}{{ end }}" style="text-decoration: none;">
<div class="logo">
{{ if .Site.Params.Logo.path }}
<img src="{{ .Site.Params.Logo.path }}" alt="{{ .Site.Params.Logo.alt }}" />
{{ else }}
<span class="logo__mark">></span>
<span class="logo__text">{{ with .Site.Params.Logo.logoText }}{{ . }}{{ else }}hello{{ end }}</span>
<span class="logo__cursor"></span>
{{ end }}
</div>
</a>

View file

@ -0,0 +1,8 @@
<nav class="menu">
<ul class="menu__inner">
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
<li><a href="{{ .URL | absLangURL }}">{{ .Name }}</a></li>
{{- end }}
</ul>
</nav>

View file

@ -0,0 +1,20 @@
<div class="pagination">
<div class="pagination__buttons">
{{ if .Paginator.HasPrev }}
<span class="button previous">
<a href="{{ .Paginator.Prev.URL }}">
<span class="button__icon"></span>
<span class="button__text">Newer posts</span>
</a>
</span>
{{ end }}
{{ if .Paginator.HasNext }}
<span class="button next">
<a href="{{ .Paginator.Next.URL }}">
<span class="button__text">Older posts</span>
<span class="button__icon"></span>
</a>
</span>
{{ end }}
</div>
</div>

View file

@ -0,0 +1,3 @@
{{ range . -}}
&nbsp; <a href="{{ .url }}" target="_blank" rel="noopener" title="{{ .name | humanize }}">{{ partial "svg.html" . }}</a> &nbsp;
{{- end -}}

25
layouts/partials/svg.html Normal file
View file

@ -0,0 +1,25 @@
{{- if (eq .name "codepen") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-codepen"><polygon points="12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2"></polygon><line x1="12" y1="22" x2="12" y2="15.5"></line><polyline points="22 8.5 12 15.5 2 8.5"></polyline><polyline points="2 15.5 12 8.5 22 15.5"></polyline><line x1="12" y1="2" x2="12" y2="8.5"></line></svg>
{{- else if (eq .name "facebook") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-facebook"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path></svg>
{{- else if (eq .name "github") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-github"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>
{{- else if (eq .name "gitlab") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-gitlab"><path d="M22.65 14.39L12 22.13 1.35 14.39a.84.84 0 0 1-.3-.94l1.22-3.78 2.44-7.51A.42.42 0 0 1 4.82 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.49h8.1l2.44-7.51A.42.42 0 0 1 18.6 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.51L23 13.45a.84.84 0 0 1-.35.94z"></path></svg>
{{- else if (eq .name "instagram") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-instagram"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path><line x1="17.5" y1="6.5" x2="17.5" y2="6.5"></line></svg>
{{- else if (eq .name "linkedin") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-linkedin"><path d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z"></path><rect x="2" y="9" width="4" height="12"></rect><circle cx="4" cy="4" r="2"></circle></svg>
{{- else if (eq .name "slack") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-slack"><path d="M22.08 9C19.81 1.41 16.54-.35 9 1.92S-.35 7.46 1.92 15 7.46 24.35 15 22.08 24.35 16.54 22.08 9z"></path><line x1="12.57" y1="5.99" x2="16.15" y2="16.39"></line><line x1="7.85" y1="7.61" x2="11.43" y2="18.01"></line><line x1="16.39" y1="7.85" x2="5.99" y2="11.43"></line><line x1="18.01" y1="12.57" x2="7.61" y2="16.15"></line></svg>
{{- else if (eq .name "twitter") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-twitter"><path d="M23 3a10.9 10.9 0 0 1-3.14 1.53 4.48 4.48 0 0 0-7.86 3v1A10.66 10.66 0 0 1 3 4s-4 9 5 13a11.64 11.64 0 0 1-7 2c9 5 20 0 20-11.5a4.5 4.5 0 0 0-.08-.83A7.72 7.72 0 0 0 23 3z"></path></svg>
{{- else if (eq .name "youtube") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-youtube"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"></path><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02"></polygon></svg>
{{- else if (eq .name "email") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-mail"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>
{{- else if (eq .name "telegram") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-send"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>
{{- else -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
{{- end -}}

View file

@ -0,0 +1,5 @@
<svg class="theme-toggler" width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M22 41C32.4934 41 41 32.4934 41 22C41 11.5066 32.4934 3 22
3C11.5066 3 3 11.5066 3 22C3 32.4934 11.5066 41 22 41ZM7 22C7
13.7157 13.7157 7 22 7V37C13.7157 37 7 30.2843 7 22Z"/>
</svg>

After

Width:  |  Height:  |  Size: 317 B

27
layouts/posts/rss.xml Normal file
View file

@ -0,0 +1,27 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end -}}
{{ range .Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description>
<content type="html">{{ printf `<![CDATA[%s]]>` .Content | safeHTML }}</content>
</item>
{{ end }}
</channel>
</rss>

94
layouts/posts/single.html Normal file
View file

@ -0,0 +1,94 @@
{{ define "main" }}
<main class="post">
<div class="post-info">
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>{{ i18n "readingTime" .Page.ReadingTime }}
{{ if .IsTranslated }}
| {{ i18n "postAvailable" }}
{{ range .Translations }}
<a href="{{ .Permalink }}"><span class="flag flag-icon flag-icon-{{ index $.Site.Data.langFlags (.Lang) }} flag-icon-squared"></span></a>
{{ end}}
{{ end }}
</p>
</div>
<article>
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
{{- if .Params.toc }}
<hr />
<aside id="toc">
<div class="toc-title">{{ i18n "tableOfContents" }}</div>
{{ .TableOfContents }}
</aside>
<hr />
{{- end }}
{{ with .Params.Cover }}
<img src="/img/{{ . }}" class="post-cover" />
{{ end }}
<div class="post-content">
{{ .Content }}
</div>
</article>
<hr />
<div class="post-info">
{{- with .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- range . -}}
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }}
</p>
{{- end }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>{{ i18n "wordCount" .Page.WordCount }}</p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>{{ if .Site.Params.dateformNumTime }}{{ dateFormat .Site.Params.dateformNumTime .Date.Local }}{{ else }}{{ dateFormat "2006-01-02 15:04 -0700" .Date.Local }}{{ end }}</p>
{{- if .GitInfo }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit"><circle cx="12" cy="12" r="4"></circle><line x1="1.05" y1="12" x2="7" y2="12"></line><line x1="17.01" y1="12" x2="22.96" y2="12"></line></svg><a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash }}</a> @ {{ if .Site.Params.dateformNum }}{{ dateFormat .Site.Params.dateformNum .GitInfo.AuthorDate.Local }}{{ else }}{{ dateFormat "2006-01-02" .GitInfo.AuthorDate.Local }}{{ end }}</p>
{{- end }}
</div>
{{ if or .NextInSection .PrevInSection }}
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">{{ .Site.Params.ReadOtherPosts }}</span>
<hr />
</div>
<div class="pagination__buttons">
{{ if .NextInSection }}
<span class="button previous">
<a href="{{ .NextInSection.Permalink }}">
<span class="button__icon"></span>
<span class="button__text">{{ .NextInSection.Title }}</span>
</a>
</span>
{{ end }}
{{ if .PrevInSection }}
<span class="button next">
<a href="{{ .PrevInSection.Permalink }}">
<span class="button__text">{{ .PrevInSection.Title }}</span>
<span class="button__icon"></span>
</a>
</span>
{{ end }}
</div>
</div>
{{ end }}
{{ if .Params.comments }}
<div id="comments" class="thin">
{{- partial "comments.html" . -}}
</div>
{{ end }}
</main>
{{ end }}

View file

@ -0,0 +1,9 @@
{{ if .Get "src" }}
<figure class="{{ with .Get "position"}}{{ . }}{{ else -}} left {{- end }}" >
<img src="{{ .Get "src" | safeURL }}" {{ with .Get "alt" }} alt="{{ . | plainify }}" {{ end }} {{ with .Get "style" }} style="{{ . | safeCSS }}" {{ end }} />
{{ if .Get "caption" }}
<figcaption class="{{ with .Get "captionPosition"}}{{ . }}{{ else -}} center {{- end }}" {{ with .Get "captionStyle" }} style="{{ . | safeCSS }}" {{ end }}>{{ .Get "caption" }}</figcaption>
{{ end }}
</figure>
{{ end }}

View file

@ -0,0 +1,3 @@
{{ if .Get "src" }}
<img src="{{ .Get "src" | safeURL }}" {{ with .Get "alt" }} alt="{{ . | plainify }}" {{ end }} class="{{ with .Get "position"}}{{ . }}{{ else -}} left {{- end }}" {{ with .Get "style" }} style="{{ . | safeCSS }}" {{ end }} />
{{ end }}

1493
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

19
package.json Normal file
View file

@ -0,0 +1,19 @@
{
"name": "hello-amigo",
"version": "1.0.0",
"main": "index.js",
"author": "Sagi Dayan <dsagidayan@gmail.com>",
"license": "MIT",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"browserslist": [
"last 2 versions",
">1%",
"not dead"
],
"devDependencies": {
"bulma": "^0.7.4",
"node-sass": "^4.11.0"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
theme.toml Normal file
View file

@ -0,0 +1,16 @@
name = "hello-amigo"
license = "MIT"
licenselink = "https://git.sagidayan.com/sagi/hugo-theme-hello-amigo/blob/master/LICENSE.md"
description = "A simple theme for Hugo. That's it."
tags = ["blog", "clean", "customizable", "dark", "highlighting", "light", "minimal", "monochromatic", "multilingual", "personal", "responsive", "simple", "technical"]
features = ["blog", "shortcode", "syntax highlighting"]
min_version = 0.30
[author]
name = "Sagi Dayan"
homepage = "https://sagidayan.com"
[original]
name = "hello-friend-ng"
homepage = "https://github.com/rhazdon/hugo-theme-hello-friend-ng"
repo = "https://github.com/rhazdon/hugo-theme-hello-friend-ng"