Updated on 2021-05-06: Since the template began to support uPagge, you can not do without names. You can find the changes by tag 1.x.x.
Discover what the Hugo - uBlog theme is all about and the core-concepts behind it.
1 Requirements
Thanks to the simplicity of Hugo, Hugo is the only dependency of this theme.
Just install latest version of :(far fa-file-archive fa-fw): Hugo (> 0.62.0) for your OS (Windows, Linux, macOS).
2 Installation
The following steps are here to help you initialize your new website. If you don’t know Hugo at all, we strongly suggest you learn more about it by following this great documentation for beginners.
2.1 Create Your Project
Hugo provides a new command to create a new website:
|
2.2 Install the Theme
The uBlogger theme’s repository is: https://github.com/upagge/uBlogger.
You can download the latest release :(far fa-file-archive fa-fw): .zip file of the theme and extract it in the themes directory.
Alternatively, clone this repository to the themes directory:
|
Or, create an empty git repository and make this repository a submodule of your site directory:
|
2.3 Basic Configuration
The following is a basic configuration for the uBlogger theme:
|
--theme option. However, we suggest you modify the configuration file (config.toml) and set the theme as the default.2.4 Create Your First Post
Here is the way to create your first post:
|
Feel free to edit the post file by adding some sample content and replacing the title value in the beginning of the file.
draft: true from the metadata, set the property draft: false or add -D/--buildDrafts parameter to hugo command.2.5 Launching the Website Locally
Launch by using the following command:
|
Go to http://localhost:1313.
hugo serve, when the contents of the files change, the page automatically refreshes with the changes.Since the theme use .Scratch in Hugo to implement some features,
it is highly recommended that you add --disableFastRender parameter to hugo server command for the live preview of the page you are editing.
|
2.6 Build the Website
When your site is ready to deploy, run the following command:
|
A public folder will be generated, containing all static content and assets for your website. It can now be deployed on any web server.
3 Configuration
3.1 Site Configuration
In addition to Hugo global configuration and menu configuration, uBlogger lets you define the following parameters in your site configuration (here is a config.toml, whose values are default).
Please open the code block below to view the complete sample configuration :(far fa-hand-point-down fa-fw)::
|
Default environments are development with hugo serve and production with hugo.
Due to limitations in the local development environment,
the comment system, CDN and fingerprint will not be enabled in the development environment.
You could enable these features with hugo serve -e production.
You can directly set your ID to get a default social link and its icon:
|
The social link generated is https://mastodon.technology/@xxxx.
Or You can set more options through a dict:
|
The default data of all supported social links is located in themes/uBlogger/assets/data/social.yaml,
which is you can refer to.
3.2 Favicons, Browserconfig, Manifest
It is recommended to put your own favicons:
- 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)
into /static. They’re easily created via https://realfavicongenerator.net/.
Customize browserconfig.xml and site.webmanifest to set theme-color and background-color.
3.3 Style Customization
uBlogger theme has been built to be as configurable as possible by defining custom .scss style files.
The directory including the custom .scss style files is assets/css relative to your project root directory.
In assets/css/_override.scss, you can override the variables in themes/uBlogger/assets/css/_variables.scss to customize the style.
Here is a example:
|
In assets/css/_custom.scss, you can add some css style code to customize the style.
4 Multilingual and i18n
uBlogger theme is fully compatible with Hugo multilingual mode, which provides in-browser language switching.
4.1 Compatibility
| Language | Hugo Code | HTML lang Attribute |
Theme Docs | Lunr.js Support |
|---|---|---|---|---|
| English | en |
en |
:(far fa-check-square fa-fw): | :(far fa-check-square fa-fw): |
| Simplified Chinese | zh-cn |
zh-CN |
:(far fa-check-square fa-fw): | :(far fa-check-square fa-fw): |
| French | fr |
fr |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Polish | pl |
pl |
:(far fa-square fa-fw): | :(far fa-square fa-fw): |
| Brazilian Portuguese | pt-br |
pt-BR |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Italian | it |
it |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Spanish | es |
es |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| German | de |
de |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| German | de |
de |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Serbian | sr |
sr |
:(far fa-square fa-fw): | :(far fa-square fa-fw): |
| Russian | ru |
ru |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Romanian | ro |
ro |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Vietnamese | vi |
vi |
:(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
4.2 Basic Configuration
After learning how Hugo handle multilingual websites, define your languages in your site configuration.
For example with English, Chinese and French website:
|
Then, for each new page, append the language code to the file name.
Single file my-page.md is split in three files:
- in English:
my-page.en.md - in Chinese:
my-page.zh-cn.md - in French:
my-page.fr.md
4.3 Overwrite Translation Strings
Translations strings are used for common default values used in the theme. Translations are available in some languages, but you may use another language or want to override default values.
To override these values, create a new file in your local i18n folder i18n/<languageCode>.toml and inspire yourself from themes/uBlogger/i18n/en.toml.
By the way, as these translations could be used by other people, please take the time to propose a translation by :(fas fa-code-branch fa-fw): making a PR to the theme!
5 Search
Based on Lunr.js or algolia, searching is supported in uBlogger theme.
5.1 Output Configuration
In order to generate index.json for searching, add JSON output file type to the home of the outputs part in your site configuration.
|
5.2 Search Configuration
Based on index.json generated by Hugo, you could activate searching.
Here is the search configuration in your site configuration:
|
The following is a comparison of two search engines:
lunr: simple, no need to synchronizeindex.json, no limit forcontentLength, but high bandwidth and low performance (Especially for Chinese which needs a large segmentit library)algolia: high performance and low bandwidth, but need to synchronizeindex.jsonand limit forcontentLength
The content of the post is separated by
h2 and h3 HTML tag to improve query performance and basically implement full-text search.
contentLength is used to limit the max index length of the part starting with h2 and h3 HTML tag.
index.json files to algolia to activate searching.
You could upload the index.json files by browsers but a CLI tool may be better.
Algolia Atomic is a good choice.
To be compatible with Hugo multilingual mode,
you need to upload different index.json for each language to the different index of algolia, such as zh-cn/index.json or fr/index.json…
Комментарии