feat: enable theme to be used as Hugo module (#169)

This commit is contained in:
Andreas Deininger
2024-03-10 08:28:55 +01:00
committed by GitHub
parent f321f1c1d5
commit 3356999b5b
16 changed files with 88 additions and 36 deletions
+32 -8
View File
@@ -49,7 +49,33 @@ Built with Hugo, SCSS, and vanilla JavaScript.
> **Note**
> You must have the [Hugo extended version](https://gohugo.io/installation/linux/#editions) installed in order to use this theme. This theme uses SCSS for styling. With the Hugo extended version, SCSS can be compiled to CSS without any additional tools.
To create a new Hugo site with this theme, run the following command:
### Using the theme as Hugo module
First create a new Hugo site by running the following command:
hugo new site myblog
Initialize your new Hugo site as hugo module by running the following command:
hugo mod init github.com/USER/REPO
Afterwards, run this command to add hugo-blog-awesome as module to your site:
hugo mod get github.com/hugo-sid/hugo-blog-awesome
To make use of the theme, add this module configuration to your site's `hugo.toml`:
[module]
[[module.imports]]
path = "github.com/hugo-sid/hugo-blog-awesome"
To preview the theme with example content, run the following command from the `exampleSite` directory:
hugo server
### Using the theme as Git submodule
To create a new Hugo site with this theme as Git submodule, run the following command:
hugo new site myblog
@@ -62,16 +88,14 @@ To preview the theme with example content, run the following command from the `e
hugo server --themesDir ../..
## Usage
To use this theme, set the `theme` variable in your site's `config.toml` to `hugo-blog-awesome`:
To use this theme, set the `theme` variable in your site's `hugo.toml` to `hugo-blog-awesome`:
theme = "hugo-blog-awesome"
## Configuration
You can take a look at the `config.toml` file in the `exampleSite` directory for an example configuration.
It is recommended that you copy the `config.toml` file from the `exampleSite` directory to the root directory of your Hugo site. You can then edit the `config.toml` file to suit your needs.
You can take a look at the `hugo.toml` file in the `exampleSite` directory for an example configuration.
It is recommended that you copy the `hugo.toml` file from the `exampleSite` directory to the root directory of your Hugo site. You can then edit the `hugo.toml` file to suit your needs.
### Adding favicon
@@ -81,7 +105,7 @@ If you want to customize anything further, you can modify `layouts\partials\head
### Adding Social icons
Social icons can be added by congifuring `config.toml` file in the following manner.
Social icons can be added by configuring `hugo.toml` file in the following manner.
```toml
[[params.socialIcons]]
@@ -186,7 +210,7 @@ If you are trying to add an icon that is not listed above, you can modify `layou
### Enable go to top button
To enable go to top button on blog posts, set `goToTop` to `true` in `config.toml` file.
To enable go to top button on blog posts, set `goToTop` to `true` in `hugo.toml` file.
```toml
[params]
@@ -11,7 +11,7 @@ Emoji can be enabled in a Hugo project in a number of ways.
<!--more-->
The [`emojify`](https://gohugo.io/functions/emojify/) function can be called directly in templates or [Inline Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes).
To enable emoji globally, set `enableEmoji` to `true` in your site's `config.toml`. You can type emoji shorthand codes directly in content files; e.g.
To enable emoji globally, set `enableEmoji` to `true` in your site's `hugo.toml`. You can type emoji shorthand codes directly in content files; e.g.
`:see_no_evil:` :see_no_evil: `:hear_no_evil:` :hear_no_evil: `:speak_no_evil:` :speak_no_evil:
@@ -1,14 +1,14 @@
---
title: Table of content
date: 2023-05-02
description: Setup table of content in Hugo blog awesome theme
title: Inhaltsverzeichnis
date: 2024-03-04
description: Konfiguration des Inhaltsverzeichnis im Theme 'Hugo Blog Awesome'
---
## Table of content
## Inhaltsverzeichnis
This theme supports displaying table of content (ToC) in blog posts.
Dieses Theme unterstützt die Anzeige eines Inhaltsverzeichnisses (IVZ) für Blog Posts.
## Parameters
## Parameter
You can manage a ToC with two parameters:
- global `toc` parameter;
@@ -18,7 +18,7 @@ The post `toc` parameter has higher priority than the global `toc` parameter.
## Enable table of content on all posts
To enable ToC on all posts (globally) set parameter `toc` to `true` in `config.toml`.
To enable ToC on all posts (globally) set parameter `toc` to `true` in `hugo.toml`.
```toml
[params]
@@ -43,9 +43,9 @@ To enable ToC on certain posts set parameter `toc` to `true` in post settings.
To disable ToC on certain posts, you have to follow two steps.
Notice: `.Params.toc` in the post will overide `.Site.Params.toc`. After these steps, parameter `toc` in the post will be `false`.
Notice: `.Params.toc` in the post will override `.Site.Params.toc`. After these steps, parameter `toc` in the post will be `false`.
1. Set parameter `toc` to `true` in `config.toml`.
1. Set parameter `toc` to `true` in `hugo.toml`.
```toml
[params]
@@ -62,9 +62,9 @@ Notice: `.Params.toc` in the post will overide `.Site.Params.toc`. After these s
---
```
## Open table of content
## Inhaltsverzeichnis aufklappen
By default, ToC is closed. To open it by default, set parameter `tocOpen` to `true` in `config.toml`.
By default, ToC is closed. To open it by default, set parameter `tocOpen` to `true` in `hugo.toml`.
```toml
[params]
@@ -11,7 +11,7 @@ Emoji can be enabled in a Hugo project in a number of ways.
<!--more-->
The [`emojify`](https://gohugo.io/functions/emojify/) function can be called directly in templates or [Inline Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes).
To enable emoji globally, set `enableEmoji` to `true` in your site's `config.toml`. You can type emoji shorthand codes directly in content files; e.g.
To enable emoji globally, set `enableEmoji` to `true` in your site's `hugo.toml`. You can type emoji shorthand codes directly in content files; e.g.
`:see_no_evil:` :see_no_evil: `:hear_no_evil:` :hear_no_evil: `:speak_no_evil:` :speak_no_evil:
@@ -18,7 +18,7 @@ The post `toc` parameter has higher priority than the global `toc` parameter.
## Enable table of content on all posts
To enable ToC on all posts (globally) set parameter `toc` to `true` in `config.toml`.
To enable ToC on all posts (globally) set parameter `toc` to `true` in `hugo.toml`.
```toml
[params]
@@ -43,9 +43,9 @@ To enable ToC on certain posts set parameter `toc` to `true` in post settings.
To disable ToC on certain posts, you have to follow two steps.
Notice: `.Params.toc` in the post will overide `.Site.Params.toc`. After these steps, parameter `toc` in the post will be `false`.
Notice: `.Params.toc` in the post will override `.Site.Params.toc`. After these steps, parameter `toc` in the post will be `false`.
1. Set parameter `toc` to `true` in `config.toml`.
1. Set parameter `toc` to `true` in `hugo.toml`.
```toml
[params]
@@ -64,7 +64,7 @@ Notice: `.Params.toc` in the post will overide `.Site.Params.toc`. After these s
## Open table of content
By default, ToC is closed. To open it by default, set parameter `tocOpen` to `true` in `config.toml`.
By default, ToC is closed. To open it by default, set parameter `tocOpen` to `true` in `hugo.toml`.
```toml
[params]
@@ -11,7 +11,7 @@ Le emoji possono essere abilitate in un progetto Hugo in diversi modi.
<!--more-->
La funzione [`emojify`](https://gohugo.io/functions/emojify/) può essere richiamata direttamente nei modelli oppure negli [Shortcodes Inline](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes).
Per abilitare le emoji globalmente, impostate `enableEmoji` a `true` nel file `config.toml` del vostro sito. Potete digitare a mano le scorciatoie per le emoji direttamente nei file di contenuto; es.
Per abilitare le emoji globalmente, impostate `enableEmoji` a `true` nel file `hugo.toml` del vostro sito. Potete digitare a mano le scorciatoie per le emoji direttamente nei file di contenuto; es.
`:see_no_evil:` :see_no_evil: `:hear_no_evil:` :hear_no_evil: `:speak_no_evil:` :speak_no_evil:
@@ -10,7 +10,7 @@ Questo tema supporta la visualizzazione di un sommario (Table Of Content - ToC)
## Abilitare il sommario in tutti gli articoli
Per abilitare il sommario in tutti gli articoli (globalmente) è necessario impostare il parametro `toc` a `true` in `config.toml`.
Per abilitare il sommario in tutti gli articoli (globalmente) è necessario impostare il parametro `toc` a `true` in `hugo.toml`.
```toml
[params]
@@ -23,7 +23,7 @@ Per disabilitare il sommario globalmente invece, basta semplicemente cancellare
Per disabilitare il sommario solamente in alcuni articoli selezionati, è necessario seguire questi due passi.
1. Impostate il parametro `toc` a `true` in `config.toml`.
1. Impostate il parametro `toc` a `true` in `hugo.toml`.
```toml
[params]
@@ -11,7 +11,7 @@ tags:
<!--more-->
[`emojify`](https://gohugo.io/functions/emojify/) функция может быть напрямую вызвана в шаблоне или [встроенный короткий код](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes).
Для включения смайликов на весь проект, установите значение `enableEmoji = true` в файле `config.toml` вашего сайта. Вы можете набрать смайлик shorthand codes непосредственно в файле с содержимым; К примеру,
Для включения смайликов на весь проект, установите значение `enableEmoji = true` в файле `hugo.toml` вашего сайта. Вы можете набрать смайлик shorthand codes непосредственно в файле с содержимым; К примеру,
`:see_no_evil:` :see_no_evil: `:hear_no_evil:` :hear_no_evil: `:speak_no_evil:` :speak_no_evil:
@@ -18,7 +18,7 @@ description: Установка содержания для Hugo темы awesom
## Включение содержания для всех записей
Для включения содержания для всех записей (глобально) установите параметр`toc` в значение `true` в `config.toml`.
Для включения содержания для всех записей (глобально) установите параметр`toc` в значение `true` в `hugo.toml`.
```toml
[params]
@@ -43,7 +43,7 @@ description: Установка содержания для Hugo темы awesom
Для отключения содержания для определённых записей, Вам необходимо выполнить два шага.
1. Установить параметр `toc` в значение `true` в `config.toml`.
1. Установить параметр `toc` в значение `true` в `hugo.toml`.
```toml
[params]
@@ -62,7 +62,7 @@ description: Установка содержания для Hugo темы awesom
## Раскрыть содержание
По умолчанию, содержание свёрнуто. Для раскрытия содержания по умолчанию, установите параметр `tocOpen` в значение `true` в `config.toml`.
По умолчанию, содержание свёрнуто. Для раскрытия содержания по умолчанию, установите параметр `tocOpen` в значение `true` в `hugo.toml`.
```toml
[params]
+3
View File
@@ -0,0 +1,3 @@
module github.com/hugo-sid/hugo-blog-awesome/exampleSite
go 1.22.0
+2
View File
@@ -0,0 +1,2 @@
github.com/hugo-sid/hugo-blog-awesome v1.13.1-0.20240307121217-f321f1c1d5f0 h1:1Ed+wKZkOlptWQia2wyZsSSDlL+EQDbV3xZ6ZC8ixJg=
github.com/hugo-sid/hugo-blog-awesome v1.13.1-0.20240307121217-f321f1c1d5f0/go.mod h1:oRoqH9/bJDdyQqBoxI77O1oWAwVtn+fTng9MD3vR8A0=
+5
View File
@@ -0,0 +1,5 @@
go 1.22.0
use .
use .. // Local theme clone resides in parent folder of example site
// use ./themes/hugo-blog-awesome/ // Local theme clone resides in themes folder
+15 -2
View File
@@ -4,8 +4,6 @@ baseURL = 'https://hba.sid.one/'
# This is what goes in <html lang="">
languageCode = 'en-us'
theme = "hugo-blog-awesome"
# This defines how dates are formatted
defaultContentLanguage = "en-gb"
@@ -13,6 +11,20 @@ defaultContentLanguage = "en-gb"
enableEmoji = true
ignoreErrors = ["additional-script-loading-error"] # ignore error of loading additional scripts.
# traditional way: theme component resides in directory 'themes'
theme = "hugo-blog-awesome"
# modern way: pull in theme component as hugo module
#[module]
# Uncomment the next line to build and serve using local theme clone declared in the named Hugo workspace:
# workspace = "hugo-blog-awesome.work"
#[module.hugoVersion]
#extended = true
#min = "0.87.0"
#[[module.imports]]
#path = "github.com/hugo-sid/hugo-blog-awesome"
#disable = false
[services]
# To enable Google Analytics 4 (gtag.js) provide G-MEASUREMENT_ID below.
# To disable Google Analytics, simply leave the field empty or remove the next two lines
@@ -311,3 +323,4 @@ url = "https://twitter.com"
[[params.socialIcons]]
name = "Rss"
url = "/index.xml"
+3
View File
@@ -0,0 +1,3 @@
module github.com/hugo-sid/hugo-blog-awesome
go 1.22.0
+1 -1
View File
@@ -36,7 +36,7 @@
{{- if or .Params.math .Site.Params.math }}{{ partial "helpers/katex.html" . -}}{{- end -}}
{{/* Google analytics script. See config.toml to enable/disable this. */}}
{{/* Google analytics script. See hugo.toml to enable/disable this. */}}
{{- if hugo.IsProduction | or (eq site.Params.env "production") }}
{{ template "_internal/google_analytics.html" . }}
{{- end -}}
+3 -1
View File
@@ -7,7 +7,9 @@
command = "cd exampleSite && hugo --gc --themesDir ../.."
[build.environment]
HUGO_VERSION = "0.123.7"
HUGO_VERSION = "0.123.8"
GO_VERSION = "1.22.1"
NODE_VERSION = "20"
HUGO_THEME = "repo"
# Deploy Preview context: all deploys generated from