feat: add en/zh README and exampleSite files
3
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
# Hugo default output directory
|
||||
/public
|
||||
public
|
||||
resources
|
||||
|
||||
## OS Files
|
||||
# Windows
|
||||
|
|
124
README.md
|
@ -1,40 +1,53 @@
|
|||
# LoveIt Hugo Theme
|
||||
# LoveIt Theme | Hugo
|
||||
|
||||
LoveIt is a clean, elegant, simple but not simpler blog theme for Hugo based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) and [KeepIt Theme](https://github.com/liuzc/LeaveIt/) developed by [Dillon](https://dillonzq.com).
|
||||
[中文 README](README.zh.md)
|
||||
|
||||

|
||||
**LoveIt** is a **clean**, **elegant** but **advanced** blog theme for [Hugo](https://gohugo.io/).
|
||||
|
||||
It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) and [KeepIt Theme](https://github.com/liuzc/LeaveIt/).
|
||||
|
||||

|
||||
|
||||
## Demo
|
||||
|
||||
To see this theme in action, Here is a live [demo site](https://suspicious-archimedes-ab369d.netlify.com) which is rendered with this theme.
|
||||
To see this theme in action, here is a live [demo site](https://hugo-loveit-en.netlify.com) which is rendered with **LoveIt** theme.
|
||||
|
||||
People that are using **LoveIt**:
|
||||
Websites using **LoveIt** theme:
|
||||
|
||||
* [Dillon](https://dillonzq.com)
|
||||
* Yours
|
||||
|
||||
## Features
|
||||
|
||||
* Optimized for performance: 99/100 on mobile and 100/100 on desktop in Google PageSpeed Insights
|
||||
* Optimized for performance: 99/100 on mobile and 100/100 on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
|
||||
* Desktop / Mobile layouts support
|
||||
* Dark / Light mode
|
||||
* Optimized SEO performance with a correct SEO SCHEMA based on JSON-LD
|
||||
* A More coerent style beetwen page and sections
|
||||
* Multilanguage support
|
||||
* Multilanguage support and I18N ready
|
||||
* Pagination support
|
||||
* Google Analytics support
|
||||
* Disqus Comment System
|
||||
* Gitalk Comment System
|
||||
* Valine Comment System
|
||||
* Gravatar Support
|
||||
* Local Avatar Support
|
||||
* [Google Analytics](https://analytics.google.com/analytics) support
|
||||
* Disqus comment system support by [Disqus](https://disqus.com)
|
||||
* Gitalk comment system support by [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* Valine comment system support by [Valine](https://valine.js.org/)
|
||||
* Gravatar support by [Gravatar](https://gravatar.com)
|
||||
* Local Avatar support
|
||||
* Up to 54 social sites supported
|
||||
* Share post support
|
||||
* Search engine verification support (Google, Bind, Yandex and Baidu)
|
||||
* Added configuration file for use on [Netlify](https://www.netlify.com)
|
||||
* Dark/Light mode
|
||||
* Up to 54 social sites supported out-of-the-box [see the list here](https://github.com/Fastbyte01/KeepIt/wiki/List-of-social-platforms-supported-out-of-box)
|
||||
* Translation ready
|
||||
* Wrap Image with Figure Tag without Shortcode. Thanks [Junian.Net](https://www.junian.net/hugo-image-figure-wrap/)
|
||||
* Load images with Lazy Load By [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* Automatically highlighting code By [Google code-prettify](https://github.com/google/code-prettify), Customizable styles via CSS. See the [themes gallery](https://rawgit.com/google/code-prettify/master/styles/index.html).
|
||||
* Automagical image gallery with [lightGallery](https://github.com/sachinchoolur/lightGallery)
|
||||
* Automatically converted images with Lazy Load by [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* Automatically highlighting code by chroma in Hugo
|
||||
* Extended markdown syntax for [Font Awesome](https://fontawesome.com/) icons
|
||||
* Math formula support by [Katex](https://katex.org/)
|
||||
* Diagram syntax shortcode support by [mermaid](https://github.com/knsv/mermaid)
|
||||
* Embedded music player support by [APlayer](https://github.com/MoePlayer/APlayer) and [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* Bilibili player support
|
||||
* Kinds of admonitions shortcode support
|
||||
* Custom align and float style shortcodes support
|
||||
* Animated typing support by [TypeIt](https://typeitjs.com/)
|
||||
* Animated coutdown support by [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* CDN support
|
||||
* ...
|
||||
|
||||
## Getting Started
|
||||
|
@ -46,7 +59,13 @@ Clone this repository to your hugo theme directory.
|
|||
git clone https://github.com/dillonzq/LoveIt.git
|
||||
```
|
||||
|
||||
Next, open config.toml in the base of the Hugo site and ensure the theme option is set to KeepIt:
|
||||
Or, make this repository a submodule of your site directory.
|
||||
|
||||
```bash
|
||||
git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt
|
||||
```
|
||||
|
||||
Next, open `config.toml` in the base of the Hugo site and ensure the theme option is set to KeepIt:
|
||||
|
||||
```bash
|
||||
theme = "LoveIt"
|
||||
|
@ -58,24 +77,25 @@ For more information read the [official setup guide](https://gohugo.io/documenta
|
|||
|
||||
Take a look in the `exampleSite` folder.
|
||||
|
||||
This directory contains an example config file and the content for the demo. It serves as an example setup for your documentation.
|
||||
This directory contains an example config file and the content for the demo for `en` and `zh` languages.
|
||||
It serves as an example setup for your website.
|
||||
|
||||
Copy the `config.toml` in the root directory of your website. Overwrite the existing config file if necessary.
|
||||
Copy the `config.toml` to the root directory of your website. Overwrite the existing config file if necessary.
|
||||
|
||||
## Content Suggestions
|
||||
|
||||
A few suggestions to help you get a good looking site quickly:
|
||||
|
||||
* Keep blog posts in the content/posts directory, for example: content/posts/my-first-post.md
|
||||
* Keep static pages in the content directory, for example: content/about.md
|
||||
* Keep media like images in the static directory, for example: static/images/2019/10/screenshot.png
|
||||
* Keep blog posts in the `content/posts` directory, for example: `content/posts/my-first-post.md`
|
||||
* Keep static pages in the `content` directory, for example: `content/about.md`
|
||||
* Keep media like images in the `static` directory, for example: `static/images/2019/9/screenshot.png`
|
||||
|
||||
## Customizing styles for your website
|
||||
|
||||
If you want to change some styling to fit your own website needs, you can edit them:
|
||||
|
||||
* `assets/css/_varibales/default.scss`: You can override the variables in `_variables.scss` to customize the style
|
||||
* `assets/css/_custom.scss` : You can put your custom css in this file
|
||||
* `assets/css/_varibales.scss`: You can override the variables in `_variables.scss` to customize the style
|
||||
* `assets/css/_custom.scss`: You can put your custom css in this file
|
||||
|
||||
## Favicons, Browserconfig, Manifest
|
||||
|
||||
|
@ -90,60 +110,60 @@ It is recommended to put your own favicons
|
|||
|
||||
into `/static`. They’re easily created via [https://realfavicongenerator.net/](https://realfavicongenerator.net/).
|
||||
|
||||
Customize browserconfig.xml and site.webmanifest to set theme-color and background-color for example.
|
||||
Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and background-color.
|
||||
|
||||
## Tips
|
||||
|
||||
### Set production environment when generating site
|
||||
### Set `production` environment when generating site
|
||||
|
||||
Because some functions are only in production mode, So you **need to add a production** environment variables when generating your site.
|
||||
Because some features are only in production mode, so you need to add a `production` environment variables when generating your site.
|
||||
|
||||
```bash
|
||||
HUGO_ENV=production hugo --gc --minify
|
||||
```
|
||||
|
||||
### Hugo “extended” Sass/SCSS version required
|
||||
|
||||
This theme write style with scss, So you must download and install the “extended” Sass/SCSS version
|
||||
|
||||
### How to toggle dark-light mode
|
||||
|
||||
* You can click the sun logo to toggle dark-light mode. In the desktop version the sun logo is to the right and in the mobile version is positioned to the left, close to the site title.
|
||||
* If you want to make your own theme toggle-able element, you can create an element with a class `.theme-switch`. See [here](https://github.com/Fastbyte01/KeepIt/blob/master/assets/js/main.js#L32)
|
||||
* You can click the circle icon to toggle dark-light mode. In the desktop version the circle icon is to the right and in the mobile version is positioned to the left, close to the site title.
|
||||
* If you want to make your own theme toggle-able element, you can create an element with a class `.theme-switch`. See [here](https://github.com/dillonzq/LoveIt/blob/master/assets/js/blog.js#L14)
|
||||
|
||||
## Home Post model
|
||||
|
||||
If you want to show posts on index instead of a personal profile, just open config.toml in the base of the Hugo site, add the following line to config.toml
|
||||
If you want to show posts on index instead of a personal profile, just open `config.toml`, add the following line:
|
||||
|
||||
```toml
|
||||
[params]
|
||||
home_mode = "post" # post or other
|
||||
home_mode = "post"
|
||||
```
|
||||
|
||||
## Add logo and cover for SEO
|
||||
|
||||
Add a logo image (127x40) and a cover image (800x600). This images are used for SEO.
|
||||
Add a logo image (127x40) and a cover image (800x600) in the `static` directory.
|
||||
|
||||
## Questions, ideas, bugs, pull requests
|
||||
|
||||
All feedback is welcome! Head over to the [issue tracker](https://github.com/dillonzq/LoveIt/issues).
|
||||
|
||||
For more configuration info or other tips you can see the [wiki](https://github.com/dillonzq/LoveIt/wiki).
|
||||
|
||||
## License
|
||||
|
||||
LeaveIt is licensed under the MIT license. Check the LICENSE file for details.
|
||||
The following resources are included in the theme:
|
||||
LoveIt is licensed under the MIT license. Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.
|
||||
|
||||
Thanks to the authors of following resources included in the theme:
|
||||
|
||||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightGallery](https://github.com/sachinchoolur/lightGallery)
|
||||
* [code-prettify](https://github.com/google/code-prettify)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [jQuery](https://github.com/jquery/jquery)
|
||||
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* [Katex](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
* [APlayer](https://github.com/MoePlayer/APlayer)
|
||||
* [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* [Valine](https://valine.js.org/)
|
||||
|
||||
## Author
|
||||
|
||||
[Dillon](https://dillonzq.com)
|
||||
|
||||
## See Also
|
||||
|
||||
* [Hermitt](https://github.com/Track3/hermit)
|
||||
* [Goa](https://github.com/shenoybr/hugo-goa)
|
||||
|
|
168
README.zh.md
Normal file
|
@ -0,0 +1,168 @@
|
|||
# LoveIt 主题 | Hugo
|
||||
|
||||
[English README](README.md)
|
||||
|
||||
[LoveIt](https://github.com/dillonzq/LoveIt) 是一个**简洁**、**优雅**且**高效**的 [Hugo](https://gohugo.io/) 博客主题。
|
||||
|
||||
它的原型基于 [LeaveIt 主题](https://github.com/liuzc/LeaveIt/) 和 [KeepIt 主题](https://github.com/liuzc/LeaveIt/)。
|
||||
|
||||

|
||||
|
||||
## 主题预览
|
||||
|
||||
为了直观地浏览主题特性,这里有一个基于 **LoveIt** 主题渲染的 [预览网站](https://hugo-loveit-zh.netlify.com)。
|
||||
|
||||
使用 **LoveIt** 主题的网站:
|
||||
|
||||
* [Dillon](https://dillonzq.com)
|
||||
* 你的网站
|
||||
|
||||
## 特性
|
||||
|
||||
* 性能优化:在 [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights) 中, 99/100 的移动设备得分和 100/100 的桌面设备得分
|
||||
* 桌面设备 / 移动设备 布局的支持
|
||||
* 暗黑 / 明亮 模式
|
||||
* 使用基于 JSON-LD 格式 的 SEO SCHEMA 文件进行 SEO 优化
|
||||
* 页面和列表保持一致的视觉样式
|
||||
* 支持多语言和国际化
|
||||
* 支持分页
|
||||
* 支持 [Google Analytics](https://analytics.google.com/analytics)
|
||||
* 支持 [Disqus](https://disqus.com) 评论系统
|
||||
* 支持 [Gitalk](https://github.com/gitalk/gitalk) 评论系统
|
||||
* 支持 [Valine](https://valine.js.org/) 评论系统
|
||||
* 支持 [Gravatar](https://gravatar.com) 头像
|
||||
* 支持本地头像
|
||||
* 支持多达 54 种社交链接
|
||||
* 支持文章分享
|
||||
* 支持搜索引擎的网站验证 (Google, Bind, Yandex and Baidu)
|
||||
* 基于 [lazysizes](https://github.com/aFarkas/lazysizes) 自动转换图片为懒加载
|
||||
* 基于 Hugo 使用的 chroma 进行代码高亮
|
||||
* 使用 [Font Awesome](https://fontawesome.com/) 图标的扩展 Markdown 语法
|
||||
* 支持基于 [Katex](https://katex.org/) 的数学公式
|
||||
* 支持基于 [mermaid](https://github.com/knsv/mermaid) 的图表和流程图生成功能
|
||||
* 支持基于 [APlayer](https://github.com/MoePlayer/APlayer) 和 [MetingJS](https://github.com/metowolf/MetingJS) 的内嵌音乐播放器
|
||||
* 支持内嵌 Bilibili 视频
|
||||
* 支持多种提醒样式的 shortcode
|
||||
* 支持自定义对齐和浮动方式的 shortcode
|
||||
* 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画
|
||||
* 支持基于 [jQuery.countdown](https://github.com/hilios/jQuery.countdown) 的倒计时动画
|
||||
* 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画
|
||||
* 支持 CDN
|
||||
* ...
|
||||
|
||||
## 快速开始
|
||||
|
||||
直接克隆这个代码库到你的 Hugo 主题目录,
|
||||
|
||||
```bash
|
||||
cd themes
|
||||
git clone https://github.com/dillonzq/LoveIt.git
|
||||
```
|
||||
|
||||
或者,把这个代码库作为子模块。
|
||||
|
||||
```bash
|
||||
git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt
|
||||
```
|
||||
|
||||
下一步, 打开 Hugo 网站的根目录下的 `config.toml` 文件来把 `theme` 设置为 `LoveIt`:
|
||||
|
||||
```bash
|
||||
theme = "LoveIt"
|
||||
```
|
||||
|
||||
更多信息请查看 Hugo 的 [官方安装指南](https://gohugo.io/documentation/)。
|
||||
|
||||
## 网站设置
|
||||
|
||||
请看一看 `exampleSite` 目录下的文件。
|
||||
|
||||
这个目录包含了 `en` 和 `zh` 两种语言的预览网站配置。它可以作为你的网站的配置模板。
|
||||
|
||||
复制 `config.toml` 文件到你的 Hugo 网站代码根目录。必要的话覆盖原始配置文件。
|
||||
|
||||
## 目录结构建议
|
||||
|
||||
以下是一些方便你清晰管理和生成文章的目录结构建议:
|
||||
|
||||
* 保持博客文章存放在 `content/posts` 目录,例如: `content/posts/我的第一篇文章.md`
|
||||
* 保持简单的静态页面存放在 `content` 目录,例如: `content/about.md`
|
||||
* 保持图片之类的媒体资源存放在 `static` 目录,例如: `static/images/2019/9/screenshot.png`
|
||||
|
||||
## 为你的网站自定义样式
|
||||
|
||||
如果你想改变一些网站样式来满足你的需求,你可以编辑:
|
||||
|
||||
* `assets/css/_varibales.scss`: 你可以覆盖 `_variables.scss` 中的变量来自定义样式
|
||||
* `assets/css/_custom.scss`: 你可以把自定义的样式放在这个文件
|
||||
|
||||
## 网站图标、浏览器配置、网站清单
|
||||
|
||||
强烈建议你把:
|
||||
|
||||
* apple-touch-icon.png (180x180)
|
||||
* favicon-32x32.png (32x32)
|
||||
* favicon-16x16.png (16x16)
|
||||
* mstile-150x150.png (150x150)
|
||||
* android-chrome-192x192.png (192x192)
|
||||
* android-chrome-512x512.png (512x512)
|
||||
|
||||
放在 `/static` 目录。利用 [https://realfavicongenerator.net/](https://realfavicongenerator.net/) 可以很容易地生成这些文件。
|
||||
|
||||
可以自定义 `browserconfig.xml` 和 `site.webmanifest` 文件来设置 theme-color 和 background-color。
|
||||
|
||||
## 小技巧
|
||||
|
||||
### 在生成网站时设置 `production` 环境变量
|
||||
|
||||
由于主题的一些功能仅在生产环境有效,所以你需要在生成网站时设置 `production` 环境变量。
|
||||
|
||||
```bash
|
||||
HUGO_ENV=production hugo --gc --minify
|
||||
```
|
||||
|
||||
### 怎样切换网站 暗黑-明亮 模式
|
||||
|
||||
* 你可以点击圆形图标来切换网站 暗黑-明亮 模式。桌面模式下圆形图标在网页右上角,移动设备模式下在网站左上角标题旁边
|
||||
* 如果你想自定义切换网站 暗黑-明亮 模式的元素,可以使用一个 class 包含 `.theme-switch` 的元素,详见[此处](https://github.com/dillonzq/LoveIt/blob/master/assets/js/blog.js#L14)
|
||||
|
||||
## 主页预览文章模式
|
||||
|
||||
如果你想在主页显示文章而不仅仅是个人信息,请打开配置文件 `config.toml`,并增加下面一行:
|
||||
|
||||
```toml
|
||||
[params]
|
||||
home_mode = "post"
|
||||
```
|
||||
|
||||
## 增加网站 logo 和封面用于 SEO 优化
|
||||
|
||||
增加一个 logo 图片 (127x40) 和一个封面图片 (800x600) 在 `static` 目录。
|
||||
|
||||
## 问题、想法、 bugs 和 PRs
|
||||
|
||||
所有的反馈都是欢迎的!详见 [issue tracker](https://github.com/dillonzq/LoveIt/issues)。
|
||||
|
||||
## 许可协议
|
||||
|
||||
LoveIt 根据 MIT 许可协议授权。 更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)。
|
||||
|
||||
感谢以下在主题中使用过的项目的作者:
|
||||
|
||||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [jQuery](https://github.com/jquery/jquery)
|
||||
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* [Katex](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
* [APlayer](https://github.com/MoePlayer/APlayer)
|
||||
* [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* [Valine](https://valine.js.org/)
|
||||
|
||||
## 作者
|
||||
|
||||
[Dillon](https://dillonzq.com)
|
|
@ -159,7 +159,7 @@
|
|||
.post-dummy-target:target {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -5.4rem;
|
||||
top: -5.6rem;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,77 +1,128 @@
|
|||
baseURL = "https://example.com"
|
||||
languageCode = "en"
|
||||
defaultContentLanguage = "en"
|
||||
title = "KeepIt"
|
||||
theme = "KeepIt"
|
||||
baseURL = "/"
|
||||
languageCode = "en" # website language
|
||||
defaultContentLanguage = "en" # [en, zh, ...] determines which i18n file to use
|
||||
title = "LoveIt Theme" # website title
|
||||
theme = "LoveIt" # theme
|
||||
enableGitInfo = false # whether to use git commit log to generate lastmod record
|
||||
hasCJKLanguage = false # whether to include chinese/japanese/korean
|
||||
paginate = 8 # amount of posts in each page only when home_mode is post
|
||||
enableEmoji = true # whether to use emoji code
|
||||
enableRobotsTXT = true # whether to use robots.txt
|
||||
googleAnalytics = "" # [UA-XXXXXXXX-X] google analytics code
|
||||
disqusShortname = "dillonzq" # Disqus shortname to use Disqus in posts
|
||||
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License."
|
||||
# copyright description used only for seo schema
|
||||
|
||||
paginate = 12
|
||||
enableEmoji = true
|
||||
enableRobotsTXT = true
|
||||
googleAnalytics = ""
|
||||
disqusShortname = "yourdiscussshortname"
|
||||
#### Syntax Highlighting (https://gohugo.io/content-management/syntax-highlighting)
|
||||
pygmentsOptions = "linenos=table"
|
||||
pygmentsCodefences = true
|
||||
pygmentsUseClasses = true
|
||||
pygmentsCodefencesGuessSyntax = true
|
||||
|
||||
[sitemap]
|
||||
changefreq = "monthly"
|
||||
staticDir = ["static", "themes/LoveIt/assets/others"] # static directories
|
||||
|
||||
[author] #### Author Info
|
||||
name = "XXXX"
|
||||
|
||||
[sitemap] #### Sitemap Info
|
||||
changefreq = "weekly"
|
||||
filename = "sitemap.xml"
|
||||
priority = 0.5
|
||||
|
||||
[blackfriday]
|
||||
hrefTargetBlank = true
|
||||
nofollowLinks = true
|
||||
noreferrerLinks = true
|
||||
[Permalinks] #### Permalinks Info (https://gohugo.io/content-management/urls/#permalinks)
|
||||
posts = "/:year/:month/:filename/"
|
||||
|
||||
[Permalinks]
|
||||
posts = "/:year/:filename/"
|
||||
|
||||
[menu]
|
||||
[menu] #### Menu Info
|
||||
[[menu.main]]
|
||||
name = "Blog"
|
||||
identifier = "posts"
|
||||
name = "Posts"
|
||||
url = "/posts/"
|
||||
weight = 1
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "tags"
|
||||
name = "Tags"
|
||||
url = "/tags/"
|
||||
weight = 2
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "categories"
|
||||
name = "Categories"
|
||||
url = "/categories/"
|
||||
weight = 3
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "about"
|
||||
name = "About"
|
||||
url = "/about"
|
||||
url = "/about/"
|
||||
weight = 4
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "zh"
|
||||
name = '<i class="fas fa-language"></i>'
|
||||
url = "https://hugo-loveit-zh.netlify.com"
|
||||
weight = 5
|
||||
|
||||
[params]
|
||||
since = 2012
|
||||
author = "Fastbyte01" # Author's name
|
||||
subtitle = "A Hugo theme" # Subtitle
|
||||
cdn_url = "" # Base CDN URL
|
||||
home_mode = "" # post or other
|
||||
version = "5.x" # LoveIt theme version
|
||||
description = "LoveIt Theme Demo" # site description
|
||||
keywords = ["XXXX", "Theme", "Hugo"] # site keywords
|
||||
|
||||
google_verification = ""
|
||||
bing_verification = ""
|
||||
yandex_verification = ""
|
||||
pinterest_verification = ""
|
||||
baidu_verification = ""
|
||||
|
||||
avatar = "/images/me/avatar.jpg" #comment it to use gravatar
|
||||
socialShare = true
|
||||
|
||||
description = "" # site description
|
||||
keywords = "" # site keywords
|
||||
#### Home Page Info
|
||||
home_mode = "post" # [post, other] home mode
|
||||
avatar = "/images/avatar.png" # URL of avatar shown in home page
|
||||
subtitle = "A Clean, Elegant but Advanced Hugo Theme" # subtitle shown in home page
|
||||
|
||||
license= 'Released under <a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
|
||||
socialShare = true # whether to show social share links in post page
|
||||
|
||||
[params.gravatar]
|
||||
#email = "example@gmail.com" #uncomment and insert your email address to use gravatar
|
||||
#### Footer CopyRight Info
|
||||
since = 2018 # Site creation time
|
||||
icp = '' # ICP info only in China (HTML format is allowed)
|
||||
license= '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
|
||||
# license info (HTML format is allowed)
|
||||
gitRepo = "" # public git repo url to link lastmod git commit only then enableGitInfo is true
|
||||
|
||||
linkToMarkdown = true # whether to show link to Raw Markdown content of the post
|
||||
|
||||
[params.social]
|
||||
#### site verification code for Google/Bing/Yandex/Pinterest/Baidu
|
||||
google_verification = ""
|
||||
bing_verification = ""
|
||||
yandex_verification = ""
|
||||
pinterest_verification = ""
|
||||
baidu_verification = ""
|
||||
|
||||
[params.cdn] #### CSS and JS Files CDN
|
||||
fontawesome_free_css = '' # for example '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.10.1/css/all.min.css" integrity="sha256-fdcFNFiBMrNfWL6OcAGQz6jDgNTRxnrLEd4vJYFWScE=" crossorigin="anonymous">'
|
||||
animate_css = ''
|
||||
gitalk_css = ''
|
||||
gitalk_js = ''
|
||||
valine_js = ''
|
||||
jquery_js = ''
|
||||
lazysizes_js = ''
|
||||
smooth_scroll_js = ''
|
||||
katex_css = ''
|
||||
katex_js = ''
|
||||
katex_auto_render_js = ''
|
||||
mermaid_js = ''
|
||||
echarts_macarons_js = ''
|
||||
echarts_js = ''
|
||||
typeit_js = ''
|
||||
jquery_countdown_js = ''
|
||||
aplayer_css = ''
|
||||
aplayer_js = ''
|
||||
meting_js = ''
|
||||
|
||||
[params.gravatar] # Gravatar Info for preferred avatar in home page
|
||||
email = ""
|
||||
|
||||
[params.social] # Social Info in home page
|
||||
GitHub = "xxxx"
|
||||
Linkedin = "xxxx"
|
||||
Twitter = "xxxx"
|
||||
#Instagram = "xxxx"
|
||||
#Email = "xxxx"
|
||||
#Email = "xxxx"
|
||||
Facebook = "xxxx"
|
||||
#Telegram = "xxxx"
|
||||
Telegram = "xxxx"
|
||||
#Medium = "xxxx"
|
||||
#Gitlab = "xxxx"
|
||||
#Youtubelegacy = "xxxx"
|
||||
|
@ -84,7 +135,7 @@ disqusShortname = "yourdiscussshortname"
|
|||
#Reddit = "xxxx"
|
||||
#Codepen = "xxxx"
|
||||
#Bitbucket = "xxxx"
|
||||
#Stackoverflow = "xxxxx"
|
||||
#Stackoverflow = "xxxx"
|
||||
#Weibo = "xxxx"
|
||||
#Odnoklassniki = "xxxx"
|
||||
#VKontakte = "xxxx"
|
||||
|
@ -123,55 +174,72 @@ disqusShortname = "yourdiscussshortname"
|
|||
#Mastodon = "xxxx"
|
||||
#Thingiverse = "xxxx"
|
||||
|
||||
[params.share]
|
||||
Twitter = true
|
||||
Facebook = true
|
||||
#Reddit = true
|
||||
Linkedin = true
|
||||
#Pinterest = true
|
||||
#HackerNews = true
|
||||
#Mix = true
|
||||
#Tumblr = true
|
||||
#VKontakte = true
|
||||
#Douban = true
|
||||
#Weibo = true
|
||||
|
||||
# Used only for Seo schema
|
||||
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License."
|
||||
|
||||
[author]
|
||||
name = "Fastbyte01"
|
||||
|
||||
[params.publisher]
|
||||
name = "Fastbyte01"
|
||||
[params.share] # Social Share Links in post page
|
||||
enable = true
|
||||
Twitter = true
|
||||
Facebook = true
|
||||
Reddit = true
|
||||
#Linkedin = true
|
||||
#Pinterest = true
|
||||
#HackerNews = true
|
||||
#Mix = true
|
||||
#Tumblr = true
|
||||
#VKontakte = true
|
||||
#Weibo = true
|
||||
|
||||
[params.publisher] # Publisher Info just for SEO
|
||||
name = "XXXX"
|
||||
[params.publisher.logo]
|
||||
url = "logo.png"
|
||||
url = "/logo.png"
|
||||
width = 127
|
||||
height = 40
|
||||
|
||||
[params.logo]
|
||||
url = "logo.png"
|
||||
[params.logo] # Website Log Info just for SEO
|
||||
url = "/logo.png"
|
||||
width = 127
|
||||
height = 40
|
||||
|
||||
[params.image]
|
||||
url = "cover.png"
|
||||
[params.image] # Website Image Info just for SEO
|
||||
url = "/cover.png"
|
||||
width = 800
|
||||
height = 600
|
||||
|
||||
[params.gitalk]
|
||||
owner = ""
|
||||
repo = ""
|
||||
clientId = ""
|
||||
clientSecret = ""
|
||||
[params.gitalk] # Gittalk Comment Config (https://github.com/gitalk/gitalk)
|
||||
owner = ""
|
||||
repo = ""
|
||||
clientId = ""
|
||||
clientSecret = ""
|
||||
|
||||
[params.valine]
|
||||
enable = false
|
||||
appId = 'your appId'
|
||||
appKey = 'your appKey'
|
||||
notify = false # mail notifier , https://github.com/xCss/Valine/wiki
|
||||
verify = false # Verification code
|
||||
avatar = 'mm'
|
||||
placeholder = 'your comments ...'
|
||||
visitor = true
|
||||
[params.valine] # Valine Comment Config (https://github.com/xCss/Valine)
|
||||
enable = false
|
||||
appId = ""
|
||||
appKey = ""
|
||||
notify = false
|
||||
verify = true
|
||||
avatar = "mp"
|
||||
placeholder = "Your comment ..."
|
||||
visitor = true
|
||||
recordIP = true
|
||||
|
||||
[privacy] #### Privacy Info (https://gohugo.io/about/hugo-and-gdpr/)
|
||||
[privacy.googleAnalytics]
|
||||
anonymizeIP = true
|
||||
|
||||
[privacy.youtube]
|
||||
privacyEnhanced = true
|
||||
|
||||
[mediaTypes] #### Options to make hugo output .md files.
|
||||
[mediaTypes."text/plain"]
|
||||
suffixes = ["md"]
|
||||
|
||||
[outputFormats.MarkDown] #### Options to make hugo output .md files.
|
||||
mediaType = "text/plain"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
|
||||
[outputs] #### Options to make hugo output .md files.
|
||||
home = ["HTML", "RSS"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
||||
|
|
|
@ -1,20 +1,64 @@
|
|||
+++
|
||||
title = "About"
|
||||
date = "2014-04-09"
|
||||
aliases = ["about-us","about-hugo","contact"]
|
||||
[ author ]
|
||||
name = "Hugo Authors"
|
||||
+++
|
||||
---
|
||||
title: "About LoveIt"
|
||||
date: 2019-08-02T11:04:49+08:00
|
||||
draft: false
|
||||
---
|
||||
|
||||
Hugo is the **world’s fastest framework for building websites**. It is written in Go.
|
||||
[LoveIt :(far fa-heart):](https://github.com/dillonzq/LoveIt) is a **clean**, **elegant** but **advanced** blog theme for [Hugo](https://gohugo.io/) developed by [Dillon](https://dillonzq.com).
|
||||
|
||||
It makes use of a variety of open source projects including:
|
||||
It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) and [KeepIt Theme](https://github.com/liuzc/LeaveIt/).
|
||||
|
||||
* 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).
|
||||
### Features
|
||||
|
||||
* :(fas fa-rocket): Optimized for performance: 99/100 on mobile and 100/100 on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
|
||||
* :(fas fa-desktop): / :(fas fa-mobile): layouts support
|
||||
* :(fas fa-moon): / :(fas fa-sun): mode
|
||||
* :(fab fa-searchengin): Optimized SEO performance with a correct SEO SCHEMA based on JSON-LD
|
||||
* :(fas fa-layer-group): A More coerent style beetwen page and sections
|
||||
* :(fas fa-language): Multilanguage support and I18N ready
|
||||
* :(fas fa-ellipsis-h): Pagination support
|
||||
* :(fab fa-google): [Google Analytics](https://analytics.google.com/analytics) support
|
||||
* :(far fa-comment): Disqus comment system support by [Disqus](https://disqus.com)
|
||||
* :(far fa-comment-dots): Gitalk comment system support by [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* :(far fa-comment-alt): Valine comment system support by [Valine](https://valine.js.org/)
|
||||
* :(far fa-user): Gravatar support by [Gravatar](https://gravatar.com)
|
||||
* :(fas fa-user-circle): Local Avatar support
|
||||
* :(far fa-id-card): Up to 54 social sites supported
|
||||
* :(fas fa-share-square): Share post support
|
||||
* :(fas fa-search): Search engine verification support (Google, Bind, Yandex and Baidu)
|
||||
* :(far fa-images): Automatically converted images with Lazy Load by [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* :(fas fa-code): Automatically highlighting code by chroma in Hugo
|
||||
* :(fab fa-font-awesome): Extended markdown syntax for [Font Awesome](https://fontawesome.com/) icons
|
||||
* :(fas fa-square-root-alt): Math formula support by [Katex](https://katex.org/)
|
||||
* :(fas fa-project-diagram): Diagram syntax shortcode support by [mermaid](https://github.com/knsv/mermaid)
|
||||
* :(fas fa-music): Embedded music player support by [APlayer](https://github.com/MoePlayer/APlayer) and [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* :(fas fa-tv): Bilibili player support
|
||||
* :(far fa-bell): Kinds of admonitions shortcode support
|
||||
* :(fas fa-align-left): Custom align and float style shortcodes support
|
||||
* :(fas fa-i-cursor): Animated typing support by [TypeIt](https://typeitjs.com/)
|
||||
* :(far fa-clock): Animated coutdown support by [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* :(fas fa-arrow-up): Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* :(fas fa-tachometer-alt): CDN support
|
||||
* ...
|
||||
|
||||
### License
|
||||
|
||||
LoveIt is licensed under the MIT license. Check the [LICENSE file](https://github.com/dillonzq/LoveIt/blob/master/LICENSE) for details.
|
||||
|
||||
Thanks to the authors of following resources included in the theme:
|
||||
|
||||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [jQuery](https://github.com/jquery/jquery)
|
||||
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* [Katex](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
* [APlayer](https://github.com/MoePlayer/APlayer)
|
||||
* [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* [Valine](https://valine.js.org/)
|
||||
|
|
25
exampleSite/content/posts/LoveIt-Preview.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: "LoveIt Theme Preview and Documentation"
|
||||
date: 2019-08-25T16:22:42+08:00
|
||||
lastmod: 2019-08-25T16:22:42+08:00
|
||||
draft: false
|
||||
description: "This is a LoveIt theme preview and documentation page."
|
||||
show_in_homepage: true
|
||||
show_description: false
|
||||
license: ''
|
||||
|
||||
tags: ['Hugo', 'Theme']
|
||||
categories: ['Documentation']
|
||||
|
||||
featured_image: ''
|
||||
featured_image_preview: ''
|
||||
|
||||
comment: true
|
||||
toc: true
|
||||
autoCollapseToc: true
|
||||
math: true
|
||||
---
|
||||
|
||||
This is a [LoveIt](https://github.com/dillonzq/LoveIt) theme preview and documentation page.
|
||||
|
||||
<!--more-->
|
|
@ -1,352 +0,0 @@
|
|||
+++
|
||||
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 © 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/>
|
|
@ -1,347 +0,0 @@
|
|||
+++
|
||||
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 © 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/
|
|
@ -1,92 +0,0 @@
|
|||
+++
|
||||
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.
|
|
@ -1,161 +0,0 @@
|
|||
---
|
||||
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).
|
|
@ -1,151 +0,0 @@
|
|||
---
|
||||
title: Migrate to Hugo from Jekyll
|
||||
date: 2014-03-10
|
||||
categories: ["Uncategorized"]
|
||||
---
|
||||
|
||||
## 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).
|
|
@ -1,10 +0,0 @@
|
|||
[build]
|
||||
command = "hugo"
|
||||
publish = "public"
|
||||
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.57"
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
[context.production.environment]
|
||||
HUGO_ENV = "production hugo --gc --minify"
|
Before ![]() (image error) Size: 35 KiB After ![]() (image error) Size: 16 KiB ![]() ![]() |
Before ![]() (image error) Size: 159 KiB After ![]() (image error) Size: 47 KiB ![]() ![]() |
Before ![]() (image error) Size: 32 KiB After ![]() (image error) Size: 10 KiB ![]() ![]() |
|
@ -3,7 +3,7 @@
|
|||
<msapplication>
|
||||
<tile>
|
||||
<square150x150logo src="/mstile-150x150.png"/>
|
||||
<TileColor>#ffc40d</TileColor>
|
||||
<TileColor>#2d89ef</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
|
|
Before ![]() (image error) Size: 195 KiB |
Before ![]() (image error) Size: 1.2 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.4 KiB After ![]() (image error) Size: 2 KiB ![]() ![]() |
Before Width: 48px | Height: 48px | Size: 12 KiB After Width: 48px | Height: 48px | Size: 15 KiB |
BIN
exampleSite/static/images/Apple-Devices-Preview.png
Normal file
After ![]() (image error) Size: 225 KiB |
BIN
exampleSite/static/images/avatar.png
Normal file
After ![]() (image error) Size: 40 KiB |
32
exampleSite/static/images/loading.svg
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
|
||||
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
|
||||
<stop stop-color="#fff" stop-opacity="0" offset="0%"/>
|
||||
<stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/>
|
||||
<stop stop-color="#fff" offset="100%"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g transform="translate(1 1)">
|
||||
<path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2">
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="rotate"
|
||||
from="0 18 18"
|
||||
to="360 18 18"
|
||||
dur="0.9s"
|
||||
repeatCount="indefinite" />
|
||||
</path>
|
||||
<circle fill="#fff" cx="36" cy="18" r="1">
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="rotate"
|
||||
from="0 18 18"
|
||||
to="360 18 18"
|
||||
dur="0.9s"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After (image error) Size: 1.3 KiB |
Before ![]() (image error) Size: 28 KiB |
Before ![]() (image error) Size: 9 KiB After ![]() (image error) Size: 40 KiB ![]() ![]() |
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 9.7 KiB ![]() ![]() |
|
@ -2,82 +2,27 @@
|
|||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="640.000000pt" height="640.000000pt" viewBox="0 0 640.000000 640.000000"
|
||||
width="560.000000pt" height="560.000000pt" viewBox="0 0 560.000000 560.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,640.000000) scale(0.100000,-0.100000)"
|
||||
<g transform="translate(0.000000,560.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M2740 6383 c-30 -8 -71 -18 -90 -23 -478 -125 -860 -405 -1136 -835
|
||||
-233 -364 -342 -823 -304 -1285 20 -249 28 -302 54 -400 14 -52 26 -105 26
|
||||
-117 0 -12 9 -46 19 -75 10 -29 22 -72 25 -95 8 -56 25 -91 46 -98 25 -8 30
|
||||
-34 31 -160 1 -197 38 -584 62 -655 8 -25 18 -67 22 -95 3 -27 10 -66 15 -85
|
||||
5 -19 16 -66 25 -105 68 -292 196 -651 302 -850 51 -93 134 -217 192 -284 36
|
||||
-42 72 -83 79 -92 10 -13 6 -29 -22 -92 l-35 -75 -253 -82 c-360 -116 -485
|
||||
-155 -553 -175 -33 -10 -91 -28 -130 -40 -38 -12 -97 -30 -130 -40 -33 -9 -71
|
||||
-21 -85 -25 -14 -5 -59 -18 -100 -30 -309 -90 -497 -171 -547 -233 -15 -19
|
||||
-23 -22 -53 -15 -60 13 -97 0 -133 -46 -53 -67 -67 -108 -67 -196 l0 -80 3200
|
||||
0 3200 0 0 72 c0 53 -6 88 -25 134 -32 80 -92 181 -119 199 -27 19 -89 19
|
||||
-126 0 -28 -15 -33 -13 -141 40 -61 30 -143 67 -183 81 -173 64 -277 101 -516
|
||||
185 -356 126 -392 139 -415 150 -11 5 -146 56 -299 114 -153 58 -285 113 -292
|
||||
123 -11 14 -3 27 61 97 40 44 98 118 130 165 110 162 245 465 315 710 12 41
|
||||
25 85 31 98 5 13 9 32 9 43 0 10 4 27 9 37 12 23 35 116 56 227 9 50 20 104
|
||||
26 121 5 17 9 40 9 52 0 12 4 30 10 40 8 15 15 80 40 407 5 61 9 155 9 210 1
|
||||
111 7 145 26 145 23 0 36 27 46 97 6 37 15 72 20 78 5 5 9 17 9 27 0 10 5 18
|
||||
10 18 6 0 10 16 10 35 0 45 26 173 44 217 8 18 14 52 14 76 1 24 6 78 13 120
|
||||
16 100 16 463 0 572 -68 473 -221 800 -535 1143 -204 224 -506 413 -796 498
|
||||
-234 69 -231 69 -662 68 -309 -1 -405 -4 -448 -16z m-277 -1048 c50 -8 139
|
||||
-29 197 -46 133 -40 298 -58 540 -58 231 0 403 19 545 58 177 50 312 66 420
|
||||
52 187 -26 248 -54 372 -177 79 -77 98 -103 133 -176 91 -194 143 -500 119
|
||||
-699 -14 -122 -10 -140 50 -224 l36 -49 -1 -131 c0 -75 -8 -168 -17 -219 -10
|
||||
-49 -17 -90 -17 -92 0 -2 -30 -20 -67 -40 -227 -125 -341 -234 -433 -413 -27
|
||||
-54 -94 -267 -114 -366 -37 -176 -41 -205 -66 -420 -18 -152 -26 -205 -33
|
||||
-211 -9 -9 -5 -16 -72 111 -124 236 -151 259 -360 301 -38 8 -106 21 -150 30
|
||||
-156 31 -233 20 -308 -46 l-37 -32 -44 37 c-82 67 -149 75 -316 39 -36 -8 -96
|
||||
-21 -135 -29 -187 -38 -239 -73 -311 -212 -94 -180 -107 -203 -115 -203 -11 0
|
||||
-13 15 -33 180 -9 74 -23 169 -30 210 -28 151 -35 186 -50 250 -8 36 -21 98
|
||||
-30 138 -21 98 -88 265 -130 328 -19 28 -56 73 -83 100 -53 53 -198 156 -278
|
||||
197 -27 14 -58 31 -67 39 -29 22 -52 157 -52 313 -1 150 1 159 61 225 31 34
|
||||
37 74 23 166 -12 79 -8 202 10 299 59 314 111 447 222 573 115 129 200 178
|
||||
358 205 57 10 176 6 263 -8z m1162 -3117 c155 -47 206 -112 186 -235 -16 -106
|
||||
-91 -174 -258 -234 -32 -11 -67 -25 -78 -30 -11 -5 -45 -18 -75 -28 -44 -16
|
||||
-56 -17 -58 -6 -5 20 142 248 201 312 23 25 17 40 -10 28 -21 -9 -15 -8 -124
|
||||
-30 -124 -24 -457 -12 -507 19 -7 4 -21 4 -33 1 -19 -6 -18 -9 14 -48 89 -111
|
||||
177 -253 177 -289 0 -10 -25 -4 -80 19 -57 24 -72 30 -145 57 -152 56 -231
|
||||
129 -246 229 -10 63 2 115 38 157 70 83 169 99 613 95 265 -2 345 -5 385 -17z
|
||||
m-205 -1377 c0 -6 -4 -13 -10 -16 -5 -3 -19 -36 -30 -73 -18 -56 -20 -81 -15
|
||||
-152 6 -75 23 -174 41 -236 5 -20 1 -21 -113 -27 -65 -4 -131 -10 -147 -13
|
||||
l-28 -7 6 74 c3 41 9 130 12 199 l6 125 -35 68 -36 67 175 0 c102 0 174 -4
|
||||
174 -9z"/>
|
||||
<path d="M2080 4221 c-67 -10 -122 -27 -169 -54 -51 -30 -143 -98 -139 -103 3
|
||||
-2 27 7 54 20 89 43 144 57 228 57 100 0 148 -9 318 -61 73 -23 166 -50 205
|
||||
-61 91 -24 262 -30 286 -10 53 44 -24 93 -208 134 -38 9 -111 25 -162 37 -195
|
||||
43 -311 55 -413 41z"/>
|
||||
<path d="M4100 4219 c-49 -8 -117 -22 -355 -76 -142 -31 -225 -70 -225 -104 0
|
||||
-35 29 -44 132 -42 104 3 154 14 376 83 170 52 218 61 318 61 83 0 139 -14
|
||||
227 -56 26 -13 47 -20 47 -17 -1 9 -84 72 -133 100 -21 12 -63 29 -93 38 -62
|
||||
18 -216 25 -294 13z"/>
|
||||
<path d="M2079 3923 c-138 -26 -179 -85 -140 -198 36 -102 130 -178 263 -214
|
||||
73 -20 318 -3 403 28 25 9 21 10 -30 5 -108 -11 -115 -9 -83 16 55 42 86 167
|
||||
57 222 -10 19 -9 20 16 14 57 -14 139 -76 186 -139 24 -34 28 -36 34 -18 14
|
||||
46 -43 128 -131 186 -151 101 -370 138 -575 98z m164 -69 c3 -4 -2 -17 -12
|
||||
-30 -32 -40 -45 -117 -31 -171 12 -41 70 -113 92 -113 4 0 8 -4 8 -9 0 -14
|
||||
-121 18 -171 46 -65 35 -115 86 -135 140 -20 52 -14 68 35 96 42 25 200 55
|
||||
214 41z m279 -59 c8 -18 8 -29 1 -36 -13 -13 -36 -2 -28 12 4 5 1 9 -5 9 -6 0
|
||||
-8 5 -4 12 4 6 3 8 -3 5 -6 -4 -16 0 -23 8 -11 13 -8 15 19 15 24 0 34 -6 43
|
||||
-25z m-233 -204 c7 -5 11 -14 7 -19 -9 -15 -36 -4 -36 14 0 16 9 18 29 5z"/>
|
||||
<path d="M4020 3933 c-63 -11 -176 -46 -223 -69 -103 -52 -197 -153 -197 -211
|
||||
0 -27 26 -31 34 -5 11 34 84 97 151 131 37 18 69 31 71 28 3 -2 0 -16 -6 -31
|
||||
-16 -42 -12 -100 9 -149 21 -48 64 -86 54 -47 -4 14 0 20 10 20 24 0 29 -16
|
||||
15 -42 -7 -13 -14 -25 -15 -26 -3 -7 -158 21 -167 29 -12 11 -46 12 -46 1 0
|
||||
-18 169 -50 314 -59 107 -6 182 6 251 40 139 69 227 227 172 310 -23 36 -65
|
||||
56 -154 73 -69 13 -215 17 -273 7z m240 -89 c54 -8 121 -36 139 -58 21 -25 0
|
||||
-83 -49 -139 -47 -53 -147 -107 -198 -107 l-35 0 35 36 c21 20 41 54 48 78 17
|
||||
62 -2 134 -25 96 -9 -14 -21 -12 -39 6 -9 8 -20 13 -25 10 -5 -3 -12 10 -15
|
||||
29 -4 19 -14 39 -24 45 -13 8 -6 10 30 8 26 -1 51 2 55 5 4 4 19 6 33 3 14 -3
|
||||
45 -8 70 -12z"/>
|
||||
<path d="M2640 3560 c0 -5 9 -10 21 -10 11 0 17 5 14 10 -3 6 -13 10 -21 10
|
||||
-8 0 -14 -4 -14 -10z"/>
|
||||
<path d="M2445 5384 c-117 -28 -184 -56 -287 -122 -144 -93 -268 -261 -281
|
||||
-380 -4 -39 -26 -71 -50 -72 -4 0 -34 -27 -67 -60 -198 -201 -262 -716 -130
|
||||
-1061 11 -30 20 -54 20 -55 0 0 -21 -11 -47 -23 -56 -26 -109 -100 -119 -166
|
||||
-3 -23 -4 -122 -2 -221 3 -195 7 -208 66 -271 17 -17 48 -39 69 -48 58 -25 68
|
||||
-31 68 -41 3 -38 21 -122 42 -189 90 -286 268 -507 525 -652 l68 -38 0 -182 0
|
||||
-183 -69 0 c-44 0 -71 4 -73 12 -3 9 -16 9 -54 0 -27 -6 -100 -22 -162 -36
|
||||
-312 -70 -521 -184 -738 -400 -212 -213 -330 -428 -395 -719 -16 -68 -22 -142
|
||||
-26 -284 l-5 -193 2001 0 2001 0 0 154 c0 436 -144 777 -453 1072 -200 192
|
||||
-440 316 -712 369 -49 9 -94 21 -100 25 -17 14 -115 23 -115 11 0 -7 -27 -11
|
||||
-70 -11 l-70 0 0 184 c0 175 1 185 20 191 79 25 311 218 398 331 100 130 177
|
||||
318 218 532 3 13 12 25 22 28 40 12 88 41 115 69 59 61 62 74 65 281 2 119 -1
|
||||
207 -8 232 -17 64 -68 123 -125 146 -28 11 -52 21 -53 22 -2 1 6 15 17 31 24
|
||||
32 72 168 92 258 8 37 13 131 13 245 1 161 -2 196 -22 270 -30 113 -100 253
|
||||
-162 322 l-50 56 35 52 c100 149 79 382 -43 478 -82 65 -172 67 -317 8 -197
|
||||
-80 -279 -82 -550 -11 -163 43 -192 48 -310 50 -87 2 -150 -1 -190 -11z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before (image error) Size: 5.3 KiB After (image error) Size: 1.6 KiB |
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "",
|
||||
"short_name": "",
|
||||
"name": "LoveIt",
|
||||
"short_name": "LoveIt",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/android-chrome-192x192.png",
|
||||
|
|
1
exampleSite/themes
Symbolic link
|
@ -0,0 +1 @@
|
|||
../..
|
243
exampleSite/zh/config.toml
Normal file
|
@ -0,0 +1,243 @@
|
|||
baseURL = "/"
|
||||
languageCode = "zh" # 网站语言标识
|
||||
defaultContentLanguage = "zh" # [en, zh, ...] 设定主题的国际化
|
||||
title = "LoveIt 主题" # 网站标题
|
||||
theme = "LoveIt" # 主题
|
||||
enableGitInfo = false # 是否使用 git 信息来生成文章的上次修改时间
|
||||
hasCJKLanguage = true # 是否包括中日韩文字
|
||||
paginate = 8 # post 模式下,主页每页显示的文章数目
|
||||
enableEmoji = true # 是否使用 emoji 代码
|
||||
enableRobotsTXT = true # 是否使用 robots.txt
|
||||
googleAnalytics = "" # [UA-XXXXXXXX-X] 谷歌分析代号
|
||||
disqusShortname = "dillonzq" # Disqus 的用户名,用来在文章中启用 Disqus 评论系统
|
||||
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License."
|
||||
# 版权描述,仅仅用于 SEO
|
||||
|
||||
#### 代码高亮设置 (https://gohugo.io/content-management/syntax-highlighting)
|
||||
pygmentsOptions = "linenos=table"
|
||||
pygmentsCodefences = true
|
||||
pygmentsUseClasses = true
|
||||
pygmentsCodefencesGuessSyntax = true
|
||||
|
||||
staticDir = ["../static", "themes/LoveIt/assets/others"] # 静态文件目录
|
||||
|
||||
[author] #### 作者信息
|
||||
name = "XXXX"
|
||||
|
||||
[sitemap] #### Sitemap 信息
|
||||
changefreq = "weekly"
|
||||
filename = "sitemap.xml"
|
||||
priority = 0.5
|
||||
|
||||
[Permalinks] #### Permalinks 信息 (https://gohugo.io/content-management/urls/#permalinks)
|
||||
posts = "/:year/:month/:filename/"
|
||||
|
||||
[menu] #### 菜单信息
|
||||
[[menu.main]]
|
||||
identifier = "posts"
|
||||
name = "文章"
|
||||
url = "/posts/"
|
||||
weight = 1
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "tags"
|
||||
name = "标签"
|
||||
url = "/tags/"
|
||||
weight = 2
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "categories"
|
||||
name = "目录"
|
||||
url = "/categories/"
|
||||
weight = 3
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "about"
|
||||
name = "关于"
|
||||
url = "/about/"
|
||||
weight = 4
|
||||
|
||||
[[menu.main]]
|
||||
identifier = "en"
|
||||
name = '<i class="fas fa-language"></i>'
|
||||
url = "https://hugo-loveit-en.netlify.com"
|
||||
weight = 5
|
||||
|
||||
[params]
|
||||
version = "5.x" # LoveIt 主题版本
|
||||
description = "LoveIt 主题演示" # 网站介绍
|
||||
keywords = ["XXXX", "Theme", "Hugo"] # 网站关键词
|
||||
|
||||
#### 主页配置
|
||||
home_mode = "post" # [post, other] 主页模式
|
||||
avatar = "/images/avatar.png" # 主页显示的头像路径
|
||||
subtitle = "一个简洁、优雅且高效的 Hugo 主题" # 主页显示的网站副标题
|
||||
|
||||
socialShare = true # 在文章页面是否使用分享功能
|
||||
|
||||
#### 页面底部版权信息设置
|
||||
since = 2018 # 网站创立年份
|
||||
icp = '' # ICP 备案信息,仅在中国使用 (允许使用 HTML 格式)
|
||||
license= '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
|
||||
# 许可协议信息 (允许使用 HTML 格式)
|
||||
gitRepo = "" # 用于生成文章上次修改时间的公共 git 仓库路径,仅在 enableGitInfo 设为 true 时有效
|
||||
|
||||
linkToMarkdown = true # 是否在文章页面显示原始 Markdown 文档链接
|
||||
|
||||
#### 网站验证代码,用于 Google/Bing/Yandex/Pinterest/Baidu
|
||||
google_verification = ""
|
||||
bing_verification = ""
|
||||
yandex_verification = ""
|
||||
pinterest_verification = ""
|
||||
baidu_verification = ""
|
||||
|
||||
[params.cdn] #### CSS 和 JS 文件的 CDN 设置
|
||||
fontawesome_free_css = '' # 例如 '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.10.1/css/all.min.css" integrity="sha256-fdcFNFiBMrNfWL6OcAGQz6jDgNTRxnrLEd4vJYFWScE=" crossorigin="anonymous">'
|
||||
animate_css = ''
|
||||
gitalk_css = ''
|
||||
gitalk_js = ''
|
||||
valine_js = ''
|
||||
jquery_js = ''
|
||||
lazysizes_js = ''
|
||||
smooth_scroll_js = ''
|
||||
katex_css = ''
|
||||
katex_js = ''
|
||||
katex_auto_render_js = ''
|
||||
mermaid_js = ''
|
||||
typeit_js = ''
|
||||
jquery_countdown_js = ''
|
||||
aplayer_css = ''
|
||||
aplayer_js = ''
|
||||
meting_js = ''
|
||||
|
||||
[params.gravatar] # Gravatar 信息,用于优先在主页显示的头像
|
||||
email = ""
|
||||
|
||||
[params.social] # 主页的社交信息设置
|
||||
GitHub = "xxxx"
|
||||
Linkedin = "xxxx"
|
||||
Twitter = "xxxx"
|
||||
#Instagram = "xxxx"
|
||||
#Email = "xxxx"
|
||||
Facebook = "xxxx"
|
||||
Telegram = "xxxx"
|
||||
#Medium = "xxxx"
|
||||
#Gitlab = "xxxx"
|
||||
#Youtubelegacy = "xxxx"
|
||||
#Youtubecustom = "xxxx"
|
||||
#Youtubechannel = "xxxx"
|
||||
#Tumblr ="xxxx"
|
||||
#Quora = "xxxx"
|
||||
#Keybase = "xxxx"
|
||||
#Pinterest = "xxxx"
|
||||
#Reddit = "xxxx"
|
||||
#Codepen = "xxxx"
|
||||
#Bitbucket = "xxxx"
|
||||
#Stackoverflow = "xxxx"
|
||||
#Weibo = "xxxx"
|
||||
#Odnoklassniki = "xxxx"
|
||||
#VKontakte = "xxxx"
|
||||
#Flickr = "xxxx"
|
||||
#Xing = "xxxx"
|
||||
#Snapchat = "xxxx"
|
||||
#Soundcloud = "xxxx"
|
||||
#Spotify = "xxxx"
|
||||
#Bandcamp = "xxxx"
|
||||
#Paypal = "xxxx"
|
||||
#Fivehundredpx = "xxxx"
|
||||
#Mix = "xxxx"
|
||||
#Goodreads = "xxxx"
|
||||
#Lastfm = "xxxx"
|
||||
#Foursquare = "xxxx"
|
||||
#Hackernews = "xxxx"
|
||||
#Kickstarter = "xxxx"
|
||||
#Patreon = "xxxx"
|
||||
#Steam = "xxxx"
|
||||
#Twitch = "xxxx"
|
||||
#Strava = "xxxx"
|
||||
#Skype = "xxxx"
|
||||
#Whatsapp = "xxxx"
|
||||
#Zhihu = "xxxx"
|
||||
#Douban = "xxxx"
|
||||
#Angellist = "xxxx"
|
||||
#Slidershare = "xxxx"
|
||||
#Jsfiddle = "xxxx"
|
||||
#Deviantart = "xxxx"
|
||||
#Behance = "xxxx"
|
||||
#Dribble = "xxxx"
|
||||
#Wordpress = "xxxx"
|
||||
#Vine = "xxxx"
|
||||
#Googlescholar = "xxxx"
|
||||
#Researchgate = "xxxx"
|
||||
#Mastodon = "xxxx"
|
||||
#Thingiverse = "xxxx"
|
||||
|
||||
[params.share] # 文章页面的分享信息设置
|
||||
enable = true
|
||||
Twitter = true
|
||||
Facebook = true
|
||||
Reddit = true
|
||||
#Linkedin = true
|
||||
#Pinterest = true
|
||||
#HackerNews = true
|
||||
#Mix = true
|
||||
#Tumblr = true
|
||||
#VKontakte = true
|
||||
#Weibo = true
|
||||
|
||||
[params.publisher] # 出版者信息,仅用于 SEO
|
||||
name = "XXXX"
|
||||
[params.publisher.logo]
|
||||
url = "/logo.png"
|
||||
width = 127
|
||||
height = 40
|
||||
|
||||
[params.logo] # 网站图标信息,仅用于 SEO
|
||||
url = "/logo.png"
|
||||
width = 127
|
||||
height = 40
|
||||
|
||||
[params.image] # 网站图片信息,仅用于 SEO
|
||||
url = "/cover.png"
|
||||
width = 800
|
||||
height = 600
|
||||
|
||||
[params.gitalk] # Gittalk 评论系统设置 (https://github.com/gitalk/gitalk)
|
||||
owner = ""
|
||||
repo = ""
|
||||
clientId = ""
|
||||
clientSecret = ""
|
||||
|
||||
[params.valine] # Valine 评论系统设置 (https://github.com/xCss/Valine)
|
||||
enable = false
|
||||
appId = ""
|
||||
appKey = ""
|
||||
notify = false
|
||||
verify = true
|
||||
avatar = "mp"
|
||||
placeholder = "Your comment ..."
|
||||
visitor = true
|
||||
recordIP = true
|
||||
|
||||
[privacy] #### 隐私信息设置 (https://gohugo.io/about/hugo-and-gdpr/)
|
||||
[privacy.googleAnalytics]
|
||||
anonymizeIP = true
|
||||
|
||||
[privacy.youtube]
|
||||
privacyEnhanced = true
|
||||
|
||||
[mediaTypes] #### 用于输出 Markdown 格式文档的设置
|
||||
[mediaTypes."text/plain"]
|
||||
suffixes = ["md"]
|
||||
|
||||
[outputFormats.MarkDown] #### 用于输出 Markdown 格式文档的设置
|
||||
mediaType = "text/plain"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
|
||||
[outputs] #### 用于输出 Markdown 格式文档的设置
|
||||
home = ["HTML", "RSS"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
64
exampleSite/zh/content/about.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
title: "关于 LoveIt"
|
||||
date: 2019-08-02T11:04:49+08:00
|
||||
draft: false
|
||||
---
|
||||
|
||||
[LoveIt :(far fa-heart):](https://github.com/dillonzq/LoveIt) 是一个由 [Dillon](https://dillonzq.com) 开发的**简洁**、**优雅**且**高效**的 [Hugo](https://gohugo.io/) 博客主题。
|
||||
|
||||
它的原型基于 [LeaveIt 主题](https://github.com/liuzc/LeaveIt/) 和 [KeepIt 主题](https://github.com/liuzc/LeaveIt/)。
|
||||
|
||||

|
||||
|
||||
### 特性
|
||||
|
||||
* :(fas fa-rocket): 性能优化:在 [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights) 中, 99/100 的移动设备得分和 100/100 的桌面设备得分
|
||||
* :(fas fa-desktop): / :(fas fa-mobile): 布局的支持
|
||||
* :(fas fa-moon): / :(fas fa-sun): 模式
|
||||
* :(fab fa-searchengin): 使用基于 JSON-LD 格式 的 SEO SCHEMA 文件进行 SEO 优化
|
||||
* :(fas fa-layer-group): 页面和列表保持一致的视觉样式
|
||||
* :(fas fa-language): 支持多语言和国际化
|
||||
* :(fas fa-ellipsis-h): 支持分页
|
||||
* :(fab fa-google): 支持 [Google Analytics](https://analytics.google.com/analytics)
|
||||
* :(far fa-comment): 支持 [Disqus](https://disqus.com) 评论系统
|
||||
* :(far fa-comment-dots): 支持 [Gitalk](https://github.com/gitalk/gitalk) 评论系统
|
||||
* :(far fa-comment-alt): 支持 [Valine](https://valine.js.org/) 评论系统
|
||||
* :(far fa-user): 支持 [Gravatar](https://gravatar.com) 头像
|
||||
* :(fas fa-user-circle): 支持本地头像
|
||||
* :(far fa-id-card): 支持多达 54 种社交链接
|
||||
* :(fas fa-share-square): 支持文章分享
|
||||
* :(fas fa-search): 支持搜索引擎的网站验证 (Google, Bind, Yandex and Baidu)
|
||||
* :(far fa-images): 基于 [lazysizes](https://github.com/aFarkas/lazysizes) 自动转换图片为懒加载
|
||||
* :(fas fa-code): 基于 Hugo 使用的 chroma 进行代码高亮
|
||||
* :(fab fa-font-awesome): 使用 [Font Awesome](https://fontawesome.com/) 图标的扩展 Markdown 语法
|
||||
* :(fas fa-square-root-alt): 支持基于 [Katex](https://katex.org/) 的数学公式
|
||||
* :(fas fa-project-diagram): 支持基于 [mermaid](https://github.com/knsv/mermaid) 的图表和流程图生成功能
|
||||
* :(fas fa-music): 支持基于 [APlayer](https://github.com/MoePlayer/APlayer) 和 [MetingJS](https://github.com/metowolf/MetingJS) 的内嵌音乐播放器
|
||||
* :(fas fa-tv): 支持内嵌 Bilibili 视频
|
||||
* :(far fa-bell): 支持多种提醒样式的 shortcode
|
||||
* :(fas fa-align-left): 支持自定义对齐和浮动方式的 shortcode
|
||||
* :(fas fa-i-cursor): 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画
|
||||
* :(far fa-clock): 支持基于 [jQuery.countdown](https://github.com/hilios/jQuery.countdown) 的倒计时动画
|
||||
* :(fas fa-arrow-up): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画
|
||||
* :(fas fa-tachometer-alt): 支持 CDN
|
||||
* ...
|
||||
|
||||
### 许可协议
|
||||
|
||||
LoveIt 根据 MIT 许可协议授权。 更多信息请查看 [LICENSE 文件](https://github.com/dillonzq/LoveIt/blob/master/LICENSE)。
|
||||
|
||||
感谢以下在主题中使用过的项目的作者:
|
||||
|
||||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [jQuery](https://github.com/jquery/jquery)
|
||||
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
|
||||
* [Katex](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
* [APlayer](https://github.com/MoePlayer/APlayer)
|
||||
* [MetingJS](https://github.com/metowolf/MetingJS)
|
||||
* [Gitalk](https://github.com/gitalk/gitalk)
|
||||
* [Valine](https://valine.js.org/)
|
25
exampleSite/zh/content/posts/LoveIt-Preview.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: "LoveIt 主题特性预览与使用文档"
|
||||
date: 2019-08-25T16:22:42+08:00
|
||||
lastmod: 2019-08-25T16:22:42+08:00
|
||||
draft: false
|
||||
description: "这是一个 LoveIt 主题特性预览与使用文档的页面。"
|
||||
show_in_homepage: true
|
||||
show_description: false
|
||||
license: ''
|
||||
|
||||
tags: ['Hugo', '主题']
|
||||
categories: ['文档']
|
||||
|
||||
featured_image: ''
|
||||
featured_image_preview: ''
|
||||
|
||||
comment: true
|
||||
toc: true
|
||||
autoCollapseToc: true
|
||||
math: true
|
||||
---
|
||||
|
||||
这是一个 [LoveIt](https://github.com/dillonzq/LoveIt) 主题特性预览与使用文档的页面。
|
||||
|
||||
<!--more-->
|
1
exampleSite/zh/themes
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../..
|
|
@ -8,7 +8,7 @@ other = "Posts"
|
|||
|
||||
# === Taxonomy ===
|
||||
[all]
|
||||
other = "All "
|
||||
other = "all "
|
||||
|
||||
[tag]
|
||||
other = "Tag"
|
||||
|
|
Before ![]() (image error) Size: 320 KiB |
Before ![]() (image error) Size: 51 KiB After ![]() (image error) Size: 45 KiB ![]() ![]() |
BIN
images/tn.png
Before ![]() (image error) Size: 64 KiB After ![]() (image error) Size: 65 KiB ![]() ![]() |
|
@ -1,10 +1,10 @@
|
|||
{{ define "title" }}{{ T "all" }}{{ T .Section | default (humanize .Section) }} | {{ .Site.Title }}{{ end -}}
|
||||
{{ define "title" }}{{ T "all" | humanize}}{{ T .Section | default .Section | humanize }} | {{ .Site.Title }}{{ end -}}
|
||||
|
||||
{{ define "content" -}}
|
||||
{{ $data := .Data -}}
|
||||
<div class="post-warp archive">
|
||||
<h2 class="post-title animated pulse faster">
|
||||
{{ printf "%s%s" (T "all") (T .Section | default (humanize .Section)) }}
|
||||
{{ T "all" | humanize}}{{ T .Section | default .Section | humanize }}
|
||||
</h2>
|
||||
|
||||
{{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}
|
||||
|
|
|
@ -4,7 +4,32 @@
|
|||
<div class="post-warp single">
|
||||
<h1 class="post-title animated pulse faster">{{ .Title }}</h1>
|
||||
<div class="post-content">
|
||||
{{ .Content }}
|
||||
{{ $content := .Content }}
|
||||
{{ $REin := `<img src="([^"]+)" alt="([^"]+)?" />` }}
|
||||
{{ $REout := "<figure><img src=/images/loading.svg data-sizes=auto data-src=$1 alt=$2 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `<img src="([^"]+)" alt="([^"]+)?" title="([^"]+)?" />` }}
|
||||
{{ $REout = "<figure><img src=/images/loading.svg data-src=$1 data-sizes=auto alt=$2 title=$3 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `:\(([\w- ]+?)\):` }}
|
||||
{{ $REout = `<i class="inline-icon $1"></i>` }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `\[(.+?)\]\^\((.+?)\)` }}
|
||||
{{ $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `<sup>\[return\]</sup>` }}
|
||||
{{ $REout = printf "<sup>[%s]</sup>" (T "return") }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `<(h[23456]) (id=".+?")>` }}
|
||||
{{ $REout = `<a class="post-dummy-target" $2></a><$1>` }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `<(sup class="footnote-ref") (id="fnref:.+?")>` }}
|
||||
{{ $REout = `<a class="post-dummy-target" $2></a><$1>` }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $REin = `<(li) (id="fn:.+?")>` }}
|
||||
{{ $REout = `<$1><a class="post-dummy-target" $2></a>` }}
|
||||
{{ $content = replaceRE $REin $REout $content }}
|
||||
{{ $content | safeHTML }}
|
||||
</div>
|
||||
</div>
|
||||
{{end }}
|
|
@ -34,7 +34,7 @@
|
|||
</div>
|
||||
<div class="post-content">
|
||||
{{ if .Params.show_description }}
|
||||
<p>{{ . }}</p>
|
||||
<p>{{ .Params.description }}</p>
|
||||
{{ else }}
|
||||
{{ $summary := .Summary }}
|
||||
{{ $REin := `:\(([\w- ]+?)\):` }}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="navbar-menu">
|
||||
{{ $currentPage := . }}
|
||||
{{ range .Site.Menus.main }}
|
||||
<a class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) | or (eq $currentPage.RelPermalink .URL) }} active{{ end }}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a>
|
||||
<a class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) | or (eq $currentPage.RelPermalink .URL) }} active{{ end }}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name | safeHTML }}</a>
|
||||
{{ end }}
|
||||
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180"></i></a>
|
||||
</div>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<div class="navbar-menu" id="mobile-menu">
|
||||
{{ $currentPage := . }}
|
||||
{{ range .Site.Menus.main }}
|
||||
<a class="menu-item" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a>
|
||||
<a class="menu-item" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name | safeHTML }}</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</div>
|
||||
<div class="post-info-line">
|
||||
<div class="post-info-md">
|
||||
{{ if .Site.Params.linkToMarkDown }}
|
||||
{{ if .Site.Params.linkToMarkdown }}
|
||||
{{ with .OutputFormats.Get "markdown" }}
|
||||
<span><a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">{{ T "seeMarkDown" }}</a></span>
|
||||
{{ end }}
|
||||
|
|
|
@ -14,6 +14,15 @@
|
|||
{{ $res := resources.Get "js/lib/lazysizes/lazysizes.min.js" | resources.Minify }}
|
||||
{{ $lazysizes = printf "<script src=\"%s\"></script>" $res.RelPermalink }}
|
||||
{{ end }}
|
||||
<!-- Smooth Scroll https://github.com/cferdinandi/smooth-scroll -->
|
||||
{{ $smooth_scroll := "" }}
|
||||
{{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.smooth_scroll_js }}
|
||||
{{ $smooth_scroll = .Site.Params.cdn.smooth_scroll_js }}
|
||||
{{ else }}
|
||||
{{ $res := resources.Get "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | resources.Minify }}
|
||||
{{ $smooth_scroll = printf "<script src=\"%s\"></script>" $res.RelPermalink }}
|
||||
{{ end }}
|
||||
{{ $smooth_scroll = delimit (slice $smooth_scroll "<script>window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true});</script>") "" }}
|
||||
<!-- KaTeX https://github.com/KaTeX/KaTeX -->
|
||||
{{ $katex_css := "" }}
|
||||
{{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_css }}
|
||||
|
@ -102,15 +111,6 @@
|
|||
{{ $res := resources.Get "js/lib/meting/Meting.min.js" | resources.Minify }}
|
||||
{{ $meting = printf "<script src=\"%s\"></script>" $res.RelPermalink }}
|
||||
{{ end }}
|
||||
<!-- Smooth Scroll https://github.com/cferdinandi/smooth-scroll -->
|
||||
{{ $smooth_scroll := "" }}
|
||||
{{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.smooth_scroll_js }}
|
||||
{{ $smooth_scroll = .Site.Params.cdn.smooth_scroll_js }}
|
||||
{{ else }}
|
||||
{{ $res := resources.Get "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | resources.Minify }}
|
||||
{{ $smooth_scroll = printf "<script src=\"%s\"></script>" $res.RelPermalink }}
|
||||
{{ end }}
|
||||
{{ $smooth_scroll = delimit (slice $smooth_scroll "<script>window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true});</script>") "" }}
|
||||
|
||||
{{ $jquery | safeHTML }}
|
||||
{{ $lazysizes | safeHTML }}
|
||||
|
|
|
@ -54,8 +54,6 @@ Disallow: /
|
|||
# Block pricepi
|
||||
User-agent: pimonster
|
||||
Disallow: /
|
||||
User-agent: Pimonster
|
||||
Disallow: /
|
||||
|
||||
User-agent: SurdotlyBot
|
||||
Disallow: /
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{ define "title" }}{{ T "all" }}{{ T .Data.Plural | default (humanize .Data.Plural) }} | {{ .Site.Title }}{{ end }}
|
||||
{{ define "title" }}{{ T "all" | humanize}}{{ T .Data.Plural | default .Data.Plural | humanize }} | {{ .Site.Title }}{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
{{ $taxonomies := .Data.Plural }}
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
<div class="post-warp archive">
|
||||
<h2 class="post-title animated pulse faster">
|
||||
{{- printf "%s%s" (T "all") (T $taxonomies | default (humanize $taxonomies)) -}}
|
||||
{{ T "all" | humanize}}{{ T $taxonomies | default $taxonomies | humanize }}
|
||||
</h2>
|
||||
|
||||
<!-- Categories Page -->
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
name = "LoveIt"
|
||||
license = "MIT"
|
||||
licenselink = "https://github.com/dillonzq/LoveIt/blob/master/LICENSE"
|
||||
description = "A minimal and responsive theme for Hugo."
|
||||
homepage = "https://dillonzq.com/"
|
||||
description = "A Clean, Elegant but Advanced Hugo Theme for Hugo."
|
||||
homepage = "https://hugo-loveit-en.netlify.com"
|
||||
tags = [
|
||||
"blog",
|
||||
"minimal",
|
||||
"clean",
|
||||
"responsive",
|
||||
"gallery",
|
||||
"dark",
|
||||
"theme"
|
||||
]
|
||||
|
|