diff options
author | Hugo Aguirre <bul-ikana@users.noreply.github.com> | 2019-09-01 04:56:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-01 04:56:43 +0300 |
commit | c850140c0abdaf0380e45d489fb9227f7dac0f15 (patch) | |
tree | 18ae8a925d5347f7a81ec6d05f0a7cd6fac79879 | |
parent | 8d2fbfaca92ae8ebe90ba2c5380cfc3b8b109727 (diff) | |
parent | 16cc43476050e8d92aa728c1e5bdab2782461e65 (diff) |
Merge pull request #5 from osjupiter/feature/add-seo
add title tag and seo codes
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | layouts/partials/head.html | 3 | ||||
-rw-r--r-- | layouts/partials/seo.html | 54 |
3 files changed, 57 insertions, 2 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index c1ff15f..ba4014d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html> - {{ partial "head.html" }} + {{ partial "head.html" .}} <body> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index cb2b770..f1853f4 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -3,7 +3,8 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> -<!-- {% seo %} --> +<title>{{ .Title}}{{if .IsPage}} - {{.Site.Title}}{{ end }}</title> +{{partial "seo.html" .}} {{ $main := resources.Get "sass/main.scss" | resources.ToCSS (dict "outputStyle" "compressed")}} <link rel="stylesheet" href="{{ $main.RelPermalink }}"> diff --git a/layouts/partials/seo.html b/layouts/partials/seo.html new file mode 100644 index 0000000..817da4e --- /dev/null +++ b/layouts/partials/seo.html @@ -0,0 +1,54 @@ +<meta name="description" content="{{ if .Description }}{{ .Description | plainify }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ end }}{{ end }}"/> +<meta name="robots" content="noodp"/> +<link rel="canonical" href="{{ .Permalink }}" /> + +<!-- Twitter Card --> +<meta name="twitter:card" content="summary" /> +<meta name="twitter:description" content="{{ if .Description }}{{ .Description | plainify }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ end }}{{ end }}" /> +<meta name="twitter:title" content="{{ .Title }}{{ if .IsHome }} - {{ .Site.Params.Tagline }}{{ else }} - {{ .Site.Title }}{{ end }}" /> +<meta name="twitter:site" content="{{ .Site.Params.twitter }}" /> +<meta name="twitter:creator" content="{{ .Site.Params.twitter }}" /> + +<!-- OG data --> +<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> +<meta content="{{ .Title }}{{ if .IsHome }} - {{ .Site.Params.Tagline }}{{ else }} - {{ .Site.Title }}{{ end }}" property="og:title"> +<meta content="{{ if .Description }}{{ .Description | plainify }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ end }}{{ end }}" property="og:description"> +<meta property="og:url" content="{{ .Permalink }}" /> +<meta property="og:site_name" content="{{ .Site.Title }}" /> +{{ range .Params.categories }}<meta property="article:section" content="{{ . }}" />{{ end }} +{{ if isset .Params "date" }}<meta property="article:published_time" content="{{ time .Date }}" />{{ end }} + +<!-- JSON-LD --> +{{ if .IsHome }} +<script type="application/ld+json"> +{ + "@context": "http://schema.org", + "@type": "WebSite", + "url": "{{ .Permalink }}", + "name": "{{ .Site.Title }}", + "author": { + "@type": "Person", + "name": "{{ .Site.Params.author }}" + }, + "description": "{{ .Site.Params.description }}", +} +</script> +{{ end }} + +{{ if .IsPage }} +<script type="application/ld+json"> +{ + "@context": "http://schema.org", + "@type": "BlogPosting", + "headline": "{{ .Title }}", + "genre": "{{ range .Params.categories }}{{ . }}{{ end }}", + "url": "{{ .Permalink }}", + "datePublished": "{{ time .Date }}", + "description": "{{ if .Description }}{{ .Description | plainify }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ end }}{{ end }}", + "author": { + "@type": "Person", + "name": "{{ .Site.Author.name }}" + } + } +</script> +{{ end }} |