From 3356999b5bf2dde792c41842ac858b35588655b2 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Sun, 10 Mar 2024 08:28:55 +0100 Subject: [PATCH] feat: enable theme to be used as Hugo module (#169) --- README.md | 40 +++++++++++++++---- .../content/de/posts/emoji-support/index.md | 2 +- .../de/posts/table-of-content/index.md | 22 +++++----- .../content/en/posts/emoji-support/index.md | 2 +- .../en/posts/table-of-content/index.md | 8 ++-- .../content/it/posts/emoji-support/index.md | 2 +- .../it/posts/table-of-content/index.md | 4 +- .../content/ru/posts/emoji-support/index.md | 2 +- .../ru/posts/table-of-content/index.md | 6 +-- exampleSite/go.mod | 3 ++ exampleSite/go.sum | 2 + exampleSite/hugo-blog-awesome.work | 5 +++ exampleSite/hugo.toml | 17 +++++++- go.mod | 3 ++ layouts/partials/head.html | 2 +- netlify.toml | 4 +- 16 files changed, 88 insertions(+), 36 deletions(-) create mode 100644 exampleSite/go.mod create mode 100644 exampleSite/go.sum create mode 100644 exampleSite/hugo-blog-awesome.work create mode 100644 go.mod diff --git a/README.md b/README.md index d90594d..072212e 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/exampleSite/content/de/posts/emoji-support/index.md b/exampleSite/content/de/posts/emoji-support/index.md index 4e69961..c20ce89 100644 --- a/exampleSite/content/de/posts/emoji-support/index.md +++ b/exampleSite/content/de/posts/emoji-support/index.md @@ -11,7 +11,7 @@ Emoji can be enabled in a Hugo project in a number of ways. 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: diff --git a/exampleSite/content/de/posts/table-of-content/index.md b/exampleSite/content/de/posts/table-of-content/index.md index 53e7360..fbbef5b 100644 --- a/exampleSite/content/de/posts/table-of-content/index.md +++ b/exampleSite/content/de/posts/table-of-content/index.md @@ -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] diff --git a/exampleSite/content/en/posts/emoji-support/index.md b/exampleSite/content/en/posts/emoji-support/index.md index 4e69961..c20ce89 100644 --- a/exampleSite/content/en/posts/emoji-support/index.md +++ b/exampleSite/content/en/posts/emoji-support/index.md @@ -11,7 +11,7 @@ Emoji can be enabled in a Hugo project in a number of ways. 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: diff --git a/exampleSite/content/en/posts/table-of-content/index.md b/exampleSite/content/en/posts/table-of-content/index.md index 53e7360..f785b3c 100644 --- a/exampleSite/content/en/posts/table-of-content/index.md +++ b/exampleSite/content/en/posts/table-of-content/index.md @@ -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] diff --git a/exampleSite/content/it/posts/emoji-support/index.md b/exampleSite/content/it/posts/emoji-support/index.md index afdb366..9ce842e 100644 --- a/exampleSite/content/it/posts/emoji-support/index.md +++ b/exampleSite/content/it/posts/emoji-support/index.md @@ -11,7 +11,7 @@ Le emoji possono essere abilitate in un progetto Hugo in diversi modi. 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: diff --git a/exampleSite/content/it/posts/table-of-content/index.md b/exampleSite/content/it/posts/table-of-content/index.md index 8b6333d..ecf549f 100644 --- a/exampleSite/content/it/posts/table-of-content/index.md +++ b/exampleSite/content/it/posts/table-of-content/index.md @@ -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] diff --git a/exampleSite/content/ru/posts/emoji-support/index.md b/exampleSite/content/ru/posts/emoji-support/index.md index c4982e8..b41d0ac 100644 --- a/exampleSite/content/ru/posts/emoji-support/index.md +++ b/exampleSite/content/ru/posts/emoji-support/index.md @@ -11,7 +11,7 @@ tags: [`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: diff --git a/exampleSite/content/ru/posts/table-of-content/index.md b/exampleSite/content/ru/posts/table-of-content/index.md index ee1c8ac..f6162c9 100644 --- a/exampleSite/content/ru/posts/table-of-content/index.md +++ b/exampleSite/content/ru/posts/table-of-content/index.md @@ -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] diff --git a/exampleSite/go.mod b/exampleSite/go.mod new file mode 100644 index 0000000..745ae8f --- /dev/null +++ b/exampleSite/go.mod @@ -0,0 +1,3 @@ +module github.com/hugo-sid/hugo-blog-awesome/exampleSite + +go 1.22.0 diff --git a/exampleSite/go.sum b/exampleSite/go.sum new file mode 100644 index 0000000..95763be --- /dev/null +++ b/exampleSite/go.sum @@ -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= diff --git a/exampleSite/hugo-blog-awesome.work b/exampleSite/hugo-blog-awesome.work new file mode 100644 index 0000000..3c5acd8 --- /dev/null +++ b/exampleSite/hugo-blog-awesome.work @@ -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 \ No newline at end of file diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 7dba116..3af9687 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -4,8 +4,6 @@ baseURL = 'https://hba.sid.one/' # This is what goes in 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" + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d206dc1 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/hugo-sid/hugo-blog-awesome + +go 1.22.0 diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d538ca6..97d7f17 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -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 -}} diff --git a/netlify.toml b/netlify.toml index 158036f..a18f830 100644 --- a/netlify.toml +++ b/netlify.toml @@ -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