mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 14:14:48 +00:00
refactor: move utilities and seo to wowchemy-core/seo modules
This commit is contained in:
1 parent
18ac0b42a8
commit
8cd28ca07f
32 files changed
+255
-3
No files matched your search
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
module:
|
||||
mounts:
|
||||
- source: layouts
|
||||
target: layouts
|
||||
@@ -0,0 +1,3 @@
|
||||
module github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-core
|
||||
|
||||
go 1.15
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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 }}
|
||||
@@ -0,0 +1,30 @@
|
||||
<h2>Dependencies</h2>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Owner</th>
|
||||
<th scope="col">Path</th>
|
||||
<th scope="col">Version</th>
|
||||
<th scope="col">Time</th>
|
||||
<th scope="col">Vendor</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $i, $e := hugo.Deps }}
|
||||
<tr>
|
||||
<th scope="row">{{ add $i 1 }}</th>
|
||||
<td>{{ with .Owner }}{{.Path }}{{ end }}</td>
|
||||
<td>
|
||||
{{ .Path }}
|
||||
{{ with .Replace}}
|
||||
=> {{ .Path }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ .Version }}</td>
|
||||
<td>{{ with .Time }}{{ . }}{{ end }}</td>
|
||||
<td>{{ .Vendor }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -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/)
|
||||
@@ -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 `<head>` with:
|
||||
|
||||
```go
|
||||
{{ partial "wowchemy_seo" . }}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
[View the documentation](https://wowchemy.com/docs/hugo-tutorials/seo/)
|
||||
File renamed without changes.
@@ -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
|
||||
@@ -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
|
||||
)
|
||||
File renamed without changes.
+3
-2
@@ -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",
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,4 @@
|
||||
{{ partial "analytics/google_analytics" . }}
|
||||
{{ partial "analytics/google_tag_manager" . }}
|
||||
{{ partial "analytics/microsoft_clarity" . }}
|
||||
{{ partial "analytics/baidu_tongji" . }}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -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 }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,123 @@
|
||||
{{ $scr := .Scratch }}
|
||||
|
||||
{{/* Request search engines not to index private pages. */}}
|
||||
{{ if .Params.private }}
|
||||
<meta name="robots" content="noindex" />
|
||||
{{- end -}}
|
||||
|
||||
{{/* Attempt to load superuser (the main site author). */}}
|
||||
{{ $superuser_name := "" }}
|
||||
{{ $superuser_username := "" }}
|
||||
{{ $superuser_role := "" }}
|
||||
{{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }}
|
||||
{{ $superuser_name = .Title }}
|
||||
{{ $superuser_username = path.Base .File.Dir }}
|
||||
{{ $superuser_role = .Params.role }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Set superuser globally for `wowchemy` module's `page_author.html`. */}}
|
||||
{{ $scr.Set "superuser_username" $superuser_username }}
|
||||
|
||||
{{ with $superuser_name }}
|
||||
<meta name="author" content="{{ . }}" />
|
||||
{{ end }}
|
||||
|
||||
{{/* Generate page description. */}}
|
||||
{{ $desc := "" }}
|
||||
{{ if .Params.summary }}
|
||||
{{ $desc = .Params.summary }}
|
||||
{{ else if .Params.abstract }}
|
||||
{{ $desc = .Params.abstract }}
|
||||
{{ else if .IsPage }}
|
||||
{{ $desc = .Summary }}
|
||||
{{ else if site.Params.marketing.seo.description }}
|
||||
{{ $desc = site.Params.marketing.seo.description }}
|
||||
{{ else }}
|
||||
{{ $desc = $superuser_role }}
|
||||
{{ end }}
|
||||
<meta name="description" content="{{ $desc }}" />
|
||||
|
||||
{{/* Get all URL variations for the page. */}}
|
||||
{{ range .Translations }}
|
||||
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" />
|
||||
{{ end }}
|
||||
<link rel="alternate" hreflang="{{ site.LanguageCode | default "en-us" }}" href="{{ .Permalink }}" />
|
||||
<link rel="canonical" href="{{ .Permalink }}" />
|
||||
|
||||
{{/* Progressive Web App (PWA) Manifest */}}
|
||||
{{ with site.Home.OutputFormats.Get "WebAppManifest" }}
|
||||
<link rel="manifest" href="{{ .RelPermalink }}" />
|
||||
{{ end }}
|
||||
|
||||
{{/* Progressive Web App (PWA) Icon */}}
|
||||
<link rel="icon" type="image/png" href="{{ (partial "functions/get_icon" 32).RelPermalink }}" />
|
||||
<link rel="apple-touch-icon" type="image/png" href="{{ (partial "functions/get_icon" 180).RelPermalink }}" />
|
||||
{{ $theme_color := ($scr.Get "primary") | default site.Params.appearance.primary_color | default "#fff" }}
|
||||
<meta name="theme-color" content="{{ $theme_color }}" />
|
||||
|
||||
{{/* Get page image for social sharing. */}}
|
||||
{{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }}
|
||||
{{/* Search for an image "*featured*" in post folder */}}
|
||||
{{ $featured_image := partial "functions/get_featured_image.html" . }}
|
||||
{{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }}
|
||||
{{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }}
|
||||
{{ $og_image := "" }}
|
||||
{{ $twitter_card := "summary_large_image" }}
|
||||
{{ if (and (eq .Kind "term") $avatar_image) }}
|
||||
{{/* Match image processing in About widget to prevent generating more images than necessary. */}}
|
||||
{{ $og_image = ($avatar_image.Fill "270x270 Center").Permalink }}
|
||||
{{ $twitter_card = "summary" }}
|
||||
{{ else if $featured_image }}
|
||||
{{ $og_image = $featured_image.Permalink }}
|
||||
{{ else if $sharing_image }}
|
||||
{{ $og_image = $sharing_image.Permalink }}
|
||||
{{ else if $has_logo }}
|
||||
{{ $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
|
||||
{{ $twitter_card = "summary" }}
|
||||
{{ else }}
|
||||
{{ $og_image = (partial "functions/get_icon" 512).Permalink }}
|
||||
{{ $twitter_card = "summary" }}
|
||||
{{ end }}
|
||||
{{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}}
|
||||
|
||||
{{ $title := partial "functions/get_page_title" . }}
|
||||
|
||||
{{/* Twitter metadata. */}}
|
||||
<meta property="twitter:card" content="{{ $twitter_card }}" />
|
||||
{{ with site.Params.marketing.seo.twitter }}
|
||||
<meta property="twitter:site" content="@{{ . }}" />
|
||||
<meta property="twitter:creator" content="@{{ . }}" />
|
||||
{{ end }}
|
||||
{{- with $og_image -}}
|
||||
<meta property="twitter:image" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
|
||||
{{/* Open Graph metadata. */}}
|
||||
<meta property="og:site_name" content="{{ site.Title }}" />
|
||||
<meta property="og:url" content="{{ .Permalink }}" />
|
||||
<meta property="og:title" content="{{ $title }}" />
|
||||
<meta property="og:description" content="{{ $desc }}" />
|
||||
{{- with $og_image -}}
|
||||
<meta property="og:image" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
<meta property="og:locale" content="{{ site.LanguageCode | default "en-us" }}" />
|
||||
{{ if .IsPage }}
|
||||
{{ if not .PublishDate.IsZero }}
|
||||
<meta
|
||||
property="article:published_time"
|
||||
content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}"
|
||||
/>
|
||||
{{ else if not .Date.IsZero }}
|
||||
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}" />
|
||||
{{ end }}
|
||||
{{ if not .Lastmod.IsZero }}
|
||||
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ if not .Date.IsZero }}
|
||||
<meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}" />
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* JSONLD page metadata. */}}
|
||||
{{ partial "jsonld/main" (dict "page" . "summary" $desc) }}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{ with site.Params.marketing.verification.google }}
|
||||
<meta name="google-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.baidu }}
|
||||
<meta name="baidu-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.bing }}
|
||||
<meta name="msvalidate.01" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,6 @@
|
||||
{{/* Site Verification and Analytics */}}
|
||||
{{ partial "site_verification" . }}
|
||||
{{ partial "analytics/main" . }}
|
||||
|
||||
{{/* Load SEO tags */}}
|
||||
{{ partial "seo_tags" . }}
|
||||
File renamed without changes.
Reference in new issue
Block a user