From 46663891c3f96186b8b2ad9f3e62207210c045e8 Mon Sep 17 00:00:00 2001 From: Kim Oliver Drechsel Date: Fri, 14 Jan 2022 23:33:29 +0100 Subject: [PATCH] Add search engine optimization --- README.md | 12 +++ search_engine_optimization/README.md | 99 +++++++++++++++++++ .../archetypes/default.md | 9 ++ .../content/posts/example.md | 5 + 4 files changed, 125 insertions(+) create mode 100644 search_engine_optimization/README.md create mode 100644 search_engine_optimization/archetypes/default.md create mode 100644 search_engine_optimization/content/posts/example.md diff --git a/README.md b/README.md index 7bf6c0a..7076830 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,15 @@ A Collection of useful Hugo Shortcodes Add a automatically generated Table of Contents to any Page/Post on your Website ![Example Table of Contents in hugo](table_of_contents/table_of_contents.png) + +- ## [Search Engine Optimization](search_engine_optimization) + + Add automatically generated Search Engine Optimization to your Website + + ```html + + + + + + ``` diff --git a/search_engine_optimization/README.md b/search_engine_optimization/README.md new file mode 100644 index 0000000..cc5329d --- /dev/null +++ b/search_engine_optimization/README.md @@ -0,0 +1,99 @@ +# Search Engine Optimization in Hugo + +Add automatically generated Search Engine Optimization to your Website + +## Install + +1. Add this code to your `` structure (e.g in `layouts/_default/baseof.html`): + + ```html + + + + + + + + + + + + {{ range .AlternativeOutputFormats -}} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} + {{ end -}} + ``` + +2. Add the default key/value `private = true` to `/archetypes/default.md` + + ```yaml + --- + title: "{{ replace .Name "-" " " | title }}" + date: {{ .Date }} + draft: true + + ## Add this key with value 'false' for indexing by search engines enabled by default + private: false + --- + ``` + +## Usage + +Add these keys and values to any page's settings: + + +```toml ++++ +... +tags = ["fruit", "apple", "health"] # Fitting keywords that describe your post/page +private = true # true if you want it private/unlisted ++++ +``` + +## Preview + +### Public + +### Example Post + +```html + + + + + +``` + +#### Index + +```html + + + + + +``` + +### Private + +> 404 Page is private by default + +```html + + + + +``` \ No newline at end of file diff --git a/search_engine_optimization/archetypes/default.md b/search_engine_optimization/archetypes/default.md new file mode 100644 index 0000000..bdfbfeb --- /dev/null +++ b/search_engine_optimization/archetypes/default.md @@ -0,0 +1,9 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +date: {{ .Date }} +draft: true + +## Add this key with value 'false' for indexing by search engines enabled by default +private: false +--- + diff --git a/search_engine_optimization/content/posts/example.md b/search_engine_optimization/content/posts/example.md new file mode 100644 index 0000000..91efdf2 --- /dev/null +++ b/search_engine_optimization/content/posts/example.md @@ -0,0 +1,5 @@ ++++ +title = "Example Page" +... +private = true ++++ \ No newline at end of file