From 8cd28ca07fbda23771808fc30fe10a82480ec173 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Wed, 7 Sep 2022 21:29:32 +0100 Subject: [PATCH] refactor: move utilities and seo to wowchemy-core/seo modules --- modules/wowchemy-core/README.md | 13 ++ modules/wowchemy-core/config.yaml | 4 + modules/wowchemy-core/go.mod | 3 + .../partials/functions/get_author_name.html | 0 .../functions/get_featured_image.html | 0 .../layouts/partials/functions/get_hook.html | 0 .../layouts/partials/functions/get_icon.html | 0 .../layouts/partials/functions/get_logo.html | 0 .../partials/functions/get_logo_url.html | 0 .../partials/functions/get_page_title.html | 8 ++ .../layouts/shortcodes/dependencies.html | 30 +++++ modules/wowchemy-plugin-netlify/README.md | 7 + modules/wowchemy-seo/README.md | 27 ++++ .../assets/media/icon.png | Bin modules/wowchemy-seo/config.yaml | 10 ++ modules/wowchemy-seo/go.mod | 7 + .../layouts/_default/_markup}/sitemap.xml | 0 .../layouts/index.webmanifest | 5 +- .../partials/analytics}/baidu_tongji.html | 0 .../partials/analytics}/google_analytics.html | 0 .../analytics}/google_tag_manager.html | 0 .../layouts/partials/analytics/main.html | 4 + .../analytics}/microsoft_clarity.html | 0 .../layouts/partials/jsonld/article.html | 0 .../layouts/partials/jsonld/business.html | 0 .../layouts/partials/jsonld/event.html | 2 +- .../layouts/partials/jsonld/main.html | 0 .../layouts/partials/jsonld/website.html | 0 .../layouts/partials/seo_tags.html | 123 ++++++++++++++++++ .../layouts/partials/site_verification.html | 9 ++ .../layouts/partials/wowchemy_seo.html | 6 + .../layouts/robots.txt | 0 32 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 modules/wowchemy-core/README.md create mode 100644 modules/wowchemy-core/config.yaml create mode 100644 modules/wowchemy-core/go.mod rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_author_name.html (100%) rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_featured_image.html (100%) rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_hook.html (100%) rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_icon.html (100%) rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_logo.html (100%) rename modules/{wowchemy => wowchemy-core}/layouts/partials/functions/get_logo_url.html (100%) create mode 100644 modules/wowchemy-core/layouts/partials/functions/get_page_title.html create mode 100644 modules/wowchemy-core/layouts/shortcodes/dependencies.html create mode 100644 modules/wowchemy-seo/README.md rename modules/{wowchemy => wowchemy-seo}/assets/media/icon.png (100%) create mode 100644 modules/wowchemy-seo/config.yaml create mode 100644 modules/wowchemy-seo/go.mod rename modules/{wowchemy/layouts/_default => wowchemy-seo/layouts/_default/_markup}/sitemap.xml (100%) rename modules/{wowchemy => wowchemy-seo}/layouts/index.webmanifest (72%) rename modules/{wowchemy/layouts/partials/marketing => wowchemy-seo/layouts/partials/analytics}/baidu_tongji.html (100%) rename modules/{wowchemy/layouts/partials/marketing => wowchemy-seo/layouts/partials/analytics}/google_analytics.html (100%) rename modules/{wowchemy/layouts/partials/marketing => wowchemy-seo/layouts/partials/analytics}/google_tag_manager.html (100%) create mode 100644 modules/wowchemy-seo/layouts/partials/analytics/main.html rename modules/{wowchemy/layouts/partials/marketing => wowchemy-seo/layouts/partials/analytics}/microsoft_clarity.html (100%) rename modules/{wowchemy => wowchemy-seo}/layouts/partials/jsonld/article.html (100%) rename modules/{wowchemy => wowchemy-seo}/layouts/partials/jsonld/business.html (100%) rename modules/{wowchemy => wowchemy-seo}/layouts/partials/jsonld/event.html (94%) rename modules/{wowchemy => wowchemy-seo}/layouts/partials/jsonld/main.html (100%) rename modules/{wowchemy => wowchemy-seo}/layouts/partials/jsonld/website.html (100%) create mode 100644 modules/wowchemy-seo/layouts/partials/seo_tags.html create mode 100644 modules/wowchemy-seo/layouts/partials/site_verification.html create mode 100644 modules/wowchemy-seo/layouts/partials/wowchemy_seo.html rename modules/{wowchemy => wowchemy-seo}/layouts/robots.txt (100%) diff --git a/modules/wowchemy-core/README.md b/modules/wowchemy-core/README.md new file mode 100644 index 00000000..fc66b1d2 --- /dev/null +++ b/modules/wowchemy-core/README.md @@ -0,0 +1,13 @@ +# wowchemy-core + +Core Wowchemy utilities and integrations. + +A module for commonalities between the `wowchemy` (Bootstrap) and `wowchemy-tailwind` (Tailwind) UIs. + +## Uses + +Used in the following modules: + +- wowchemy-seo +- wowchemy +- wowchemy-tailwind diff --git a/modules/wowchemy-core/config.yaml b/modules/wowchemy-core/config.yaml new file mode 100644 index 00000000..7d9ee8af --- /dev/null +++ b/modules/wowchemy-core/config.yaml @@ -0,0 +1,4 @@ +module: + mounts: + - source: layouts + target: layouts diff --git a/modules/wowchemy-core/go.mod b/modules/wowchemy-core/go.mod new file mode 100644 index 00000000..17d476e8 --- /dev/null +++ b/modules/wowchemy-core/go.mod @@ -0,0 +1,3 @@ +module github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core + +go 1.15 diff --git a/modules/wowchemy/layouts/partials/functions/get_author_name.html b/modules/wowchemy-core/layouts/partials/functions/get_author_name.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_author_name.html rename to modules/wowchemy-core/layouts/partials/functions/get_author_name.html diff --git a/modules/wowchemy/layouts/partials/functions/get_featured_image.html b/modules/wowchemy-core/layouts/partials/functions/get_featured_image.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_featured_image.html rename to modules/wowchemy-core/layouts/partials/functions/get_featured_image.html diff --git a/modules/wowchemy/layouts/partials/functions/get_hook.html b/modules/wowchemy-core/layouts/partials/functions/get_hook.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_hook.html rename to modules/wowchemy-core/layouts/partials/functions/get_hook.html diff --git a/modules/wowchemy/layouts/partials/functions/get_icon.html b/modules/wowchemy-core/layouts/partials/functions/get_icon.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_icon.html rename to modules/wowchemy-core/layouts/partials/functions/get_icon.html diff --git a/modules/wowchemy/layouts/partials/functions/get_logo.html b/modules/wowchemy-core/layouts/partials/functions/get_logo.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_logo.html rename to modules/wowchemy-core/layouts/partials/functions/get_logo.html diff --git a/modules/wowchemy/layouts/partials/functions/get_logo_url.html b/modules/wowchemy-core/layouts/partials/functions/get_logo_url.html similarity index 100% rename from modules/wowchemy/layouts/partials/functions/get_logo_url.html rename to modules/wowchemy-core/layouts/partials/functions/get_logo_url.html diff --git a/modules/wowchemy-core/layouts/partials/functions/get_page_title.html b/modules/wowchemy-core/layouts/partials/functions/get_page_title.html new file mode 100644 index 00000000..0151e8f3 --- /dev/null +++ b/modules/wowchemy-core/layouts/partials/functions/get_page_title.html @@ -0,0 +1,8 @@ +{{ $title := "" }} +{{ with .Params.seo.title }} + {{ $title = replace . "{brand}" site.Title }} +{{ else }} + {{ $title = .Title | default site.Title }} + {{ if ne $title site.Title }}{{ $title = printf "%s | %s" $title site.Title }}{{ end }} +{{ end }} +{{ return $title }} diff --git a/modules/wowchemy-core/layouts/shortcodes/dependencies.html b/modules/wowchemy-core/layouts/shortcodes/dependencies.html new file mode 100644 index 00000000..dc8aee61 --- /dev/null +++ b/modules/wowchemy-core/layouts/shortcodes/dependencies.html @@ -0,0 +1,30 @@ +

Dependencies

+ + + + + + + + + + + + + {{ range $i, $e := hugo.Deps }} + + + + + + + + + {{ end }} + +
#OwnerPathVersionTimeVendor
{{ add $i 1 }}{{ with .Owner }}{{.Path }}{{ end }} + {{ .Path }} + {{ with .Replace}} + => {{ .Path }} + {{ end }} + {{ .Version }}{{ with .Time }}{{ . }}{{ end }}{{ .Vendor }}
diff --git a/modules/wowchemy-plugin-netlify/README.md b/modules/wowchemy-plugin-netlify/README.md index e62251f2..3f48ff4b 100644 --- a/modules/wowchemy-plugin-netlify/README.md +++ b/modules/wowchemy-plugin-netlify/README.md @@ -16,6 +16,13 @@ By default, the plugin will help secure your site with some common security head - path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify ``` +2. Tell Hugo to generate the Netlify `headers` and `redirects` files by adding them to Hugo's `outputs` config. For example, + + ```yaml + outputs: + home: [..., headers, redirects] + ``` + ## Configure - 📚 [View the **documentation**](https://wowchemy.com/docs/hugo-tutorials/security/) diff --git a/modules/wowchemy-seo/README.md b/modules/wowchemy-seo/README.md new file mode 100644 index 00000000..b2bbdb06 --- /dev/null +++ b/modules/wowchemy-seo/README.md @@ -0,0 +1,27 @@ +# wowchemy-seo + +A Wowchemy/Hugo plugin for [Search Engine Optimisation (SEO)](https://wowchemy.com/docs/hugo-tutorials/seo/), site verification, and [analytics](https://wowchemy.com/docs/hugo-tutorials/analytics/). + +## Install + +The main `wowchemy` module will automatically include the SEO module in your site so you don't have to. + +Otherwise, if you are not using the main `wowchemy` module, you can get SEO features for your Hugo site by following the guide below: + +1. Add the module to your `config/_default/config.yaml`: + + ```yaml + module: + imports: + - path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-seo + ``` + +2. If you're not using the main `wowchemy` module, load the SEO module in your site's `` with: + + ```go + {{ partial "wowchemy_seo" . }} + ``` + +## Usage + +[View the documentation](https://wowchemy.com/docs/hugo-tutorials/seo/) diff --git a/modules/wowchemy/assets/media/icon.png b/modules/wowchemy-seo/assets/media/icon.png similarity index 100% rename from modules/wowchemy/assets/media/icon.png rename to modules/wowchemy-seo/assets/media/icon.png diff --git a/modules/wowchemy-seo/config.yaml b/modules/wowchemy-seo/config.yaml new file mode 100644 index 00000000..1aa622ea --- /dev/null +++ b/modules/wowchemy-seo/config.yaml @@ -0,0 +1,10 @@ +sitemap: + changefreq: weekly +module: + mounts: + - source: assets + target: assets + - source: layouts + target: layouts + imports: + - path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core diff --git a/modules/wowchemy-seo/go.mod b/modules/wowchemy-seo/go.mod new file mode 100644 index 00000000..4c60a7e6 --- /dev/null +++ b/modules/wowchemy-seo/go.mod @@ -0,0 +1,7 @@ +module github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-seo + +go 1.15 + +require ( + github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core v0.1.0 +) diff --git a/modules/wowchemy/layouts/_default/sitemap.xml b/modules/wowchemy-seo/layouts/_default/_markup/sitemap.xml similarity index 100% rename from modules/wowchemy/layouts/_default/sitemap.xml rename to modules/wowchemy-seo/layouts/_default/_markup/sitemap.xml diff --git a/modules/wowchemy/layouts/index.webmanifest b/modules/wowchemy-seo/layouts/index.webmanifest similarity index 72% rename from modules/wowchemy/layouts/index.webmanifest rename to modules/wowchemy-seo/layouts/index.webmanifest index 3a0cd1ac..ec443066 100644 --- a/modules/wowchemy/layouts/index.webmanifest +++ b/modules/wowchemy-seo/layouts/index.webmanifest @@ -1,10 +1,11 @@ {{- $scr := .Scratch -}} +{{- $theme_color := ($scr.Get "primary") | default site.Params.appearance.primary_color | default "#fff" -}} { "name": "{{site.Title}}", "short_name": "{{site.Title}}", "lang": "{{ site.LanguageCode | default "en-us" }}", - "theme_color": "{{ $scr.Get "primary" }}", - "background_color": "{{ $scr.Get "primary" }}", + "theme_color": "{{ $theme_color }}", + "background_color": "{{ $theme_color }}", "icons": [{ "src": "{{ (partial "functions/get_icon" 192).RelPermalink }}", "sizes": "192x192", diff --git a/modules/wowchemy/layouts/partials/marketing/baidu_tongji.html b/modules/wowchemy-seo/layouts/partials/analytics/baidu_tongji.html similarity index 100% rename from modules/wowchemy/layouts/partials/marketing/baidu_tongji.html rename to modules/wowchemy-seo/layouts/partials/analytics/baidu_tongji.html diff --git a/modules/wowchemy/layouts/partials/marketing/google_analytics.html b/modules/wowchemy-seo/layouts/partials/analytics/google_analytics.html similarity index 100% rename from modules/wowchemy/layouts/partials/marketing/google_analytics.html rename to modules/wowchemy-seo/layouts/partials/analytics/google_analytics.html diff --git a/modules/wowchemy/layouts/partials/marketing/google_tag_manager.html b/modules/wowchemy-seo/layouts/partials/analytics/google_tag_manager.html similarity index 100% rename from modules/wowchemy/layouts/partials/marketing/google_tag_manager.html rename to modules/wowchemy-seo/layouts/partials/analytics/google_tag_manager.html diff --git a/modules/wowchemy-seo/layouts/partials/analytics/main.html b/modules/wowchemy-seo/layouts/partials/analytics/main.html new file mode 100644 index 00000000..a7b438f2 --- /dev/null +++ b/modules/wowchemy-seo/layouts/partials/analytics/main.html @@ -0,0 +1,4 @@ +{{ partial "analytics/google_analytics" . }} +{{ partial "analytics/google_tag_manager" . }} +{{ partial "analytics/microsoft_clarity" . }} +{{ partial "analytics/baidu_tongji" . }} diff --git a/modules/wowchemy/layouts/partials/marketing/microsoft_clarity.html b/modules/wowchemy-seo/layouts/partials/analytics/microsoft_clarity.html similarity index 100% rename from modules/wowchemy/layouts/partials/marketing/microsoft_clarity.html rename to modules/wowchemy-seo/layouts/partials/analytics/microsoft_clarity.html diff --git a/modules/wowchemy/layouts/partials/jsonld/article.html b/modules/wowchemy-seo/layouts/partials/jsonld/article.html similarity index 100% rename from modules/wowchemy/layouts/partials/jsonld/article.html rename to modules/wowchemy-seo/layouts/partials/jsonld/article.html diff --git a/modules/wowchemy/layouts/partials/jsonld/business.html b/modules/wowchemy-seo/layouts/partials/jsonld/business.html similarity index 100% rename from modules/wowchemy/layouts/partials/jsonld/business.html rename to modules/wowchemy-seo/layouts/partials/jsonld/business.html diff --git a/modules/wowchemy/layouts/partials/jsonld/event.html b/modules/wowchemy-seo/layouts/partials/jsonld/event.html similarity index 94% rename from modules/wowchemy/layouts/partials/jsonld/event.html rename to modules/wowchemy-seo/layouts/partials/jsonld/event.html index e0add5b8..02299b98 100644 --- a/modules/wowchemy/layouts/partials/jsonld/event.html +++ b/modules/wowchemy-seo/layouts/partials/jsonld/event.html @@ -1,6 +1,6 @@ {{ $page := .page }} {{ $summary := .summary }} -{{ $featured_image := partial "funcctions/get_featured_image.html" $page }} +{{ $featured_image := partial "functions/get_featured_image.html" $page }} {{ $author := partial "functions/get_author_name" $page }}