From eb920828a5c232e475e2c44512b432c2fb8e16d8 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Mon, 4 Mar 2024 20:54:00 +0100 Subject: [PATCH] Add instructions on how to use the theme as hugo module --- README.md | 40 +++++++++++++++---- .../content/de/posts/emoji-support/index.md | 2 +- .../de/posts/table-of-content/index.md | 6 +-- .../content/en/posts/emoji-support/index.md | 2 +- .../en/posts/table-of-content/index.md | 6 +-- .../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 | 5 +++ exampleSite/go.sum | 2 + exampleSite/hugo-blog-awesome.work | 5 +++ exampleSite/hugo.toml | 13 +++++- go.mod | 3 ++ layouts/partials/head.html | 2 +- netlify.toml | 7 ++-- 16 files changed, 78 insertions(+), 29 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..b52c9d4 100644 --- a/exampleSite/content/de/posts/table-of-content/index.md +++ b/exampleSite/content/de/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] @@ -45,7 +45,7 @@ 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`. -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/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..b52c9d4 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] @@ -45,7 +45,7 @@ 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`. -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..d93a9f7 --- /dev/null +++ b/exampleSite/go.mod @@ -0,0 +1,5 @@ +module github.com/hugo-sid/hugo-blog-awesome/exampleSite + +go 1.22.0 + +require github.com/hugo-sid/hugo-blog-awesome v1.13.0 // indirect diff --git a/exampleSite/go.sum b/exampleSite/go.sum new file mode 100644 index 0000000..33c7d03 --- /dev/null +++ b/exampleSite/go.sum @@ -0,0 +1,2 @@ +github.com/hugo-sid/hugo-blog-awesome v1.13.0 h1:Jy22y4EVbZDzKnwSl0bN7dyaMlvGEZZT8KV+/VIx0vE= +github.com/hugo-sid/hugo-blog-awesome v1.13.0/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 652d196..8fb31ed 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,16 @@ defaultContentLanguage = "en-gb" enableEmoji = true ignoreErrors = ["additional-script-loading-error"] # ignore error of loading additional scripts. +[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 +319,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 8a370bb..d8c15c4 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,13 +4,14 @@ [build] base = "/" publish = "exampleSite/public" - command = "cd exampleSite && hugo --gc --themesDir ../.." + command = "cd exampleSite && hugo --gc" [build.environment] HUGO_VERSION = "0.122.0" - HUGO_THEME = "repo" + GO_VERSION = "1.22.0" + NODE_VERSION = "20" # Deploy Preview context: all deploys generated from # a pull/merge request will inherit these settings. [context.deploy-preview] -command = "cd exampleSite && hugo --gc --themesDir ../.. -b $DEPLOY_PRIME_URL" +command = "cd exampleSite && hugo --gc -b $DEPLOY_PRIME_URL"