diff options
author | Guillermo Guerrero Ibarra <wolf.fox1985@gmail.com> | 2021-08-20 13:29:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 13:29:02 +0300 |
commit | da6c71b00f07f04bd5ea7faba4e10ed41953ae37 (patch) | |
tree | 64761e5a26583b5635a057ac609521654d742856 | |
parent | 38f49445bfbcd1e03f773336a46d28e03d8539ac (diff) |
Allow to add third party javascript or css libraries. (#240)1.2.3
* Allow to add third party javascript or css libraries.
* Added missing places.
* Update custom_headers.html
* Added header.
* Updated readme.
* Removed comment.
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | layouts/404.html | 5 | ||||
-rw-r--r-- | layouts/_default/list.html | 5 | ||||
-rw-r--r-- | layouts/_default/single.html | 5 | ||||
-rw-r--r-- | layouts/index.html | 5 | ||||
-rw-r--r-- | layouts/page/single.html | 5 | ||||
-rw-r--r-- | layouts/partials/custom_headers.html | 0 | ||||
-rw-r--r-- | layouts/partials/head.html | 103 | ||||
-rw-r--r-- | layouts/partials/headers.html | 100 | ||||
-rw-r--r-- | static/css/custom.css | 2 |
10 files changed, 127 insertions, 111 deletions
@@ -94,6 +94,7 @@ style = "default" ``` Available options are: `default` (light-blue), `blue`, `green`, `marsala`, `pink`, `red`, `turquoise`, `violet`. +There is the possibility to override the CSS and set your custom styles, override this file `static/css/custom.css` in your site. ### Comments @@ -529,7 +530,7 @@ summaryLength = 70 [params.recent_posts] enable = true title = "From our blog" - subtitle = "Pellen + subtitle = "Pellen" hide_summary = false ``` @@ -641,6 +642,11 @@ Which results in the following HTML: <meta name="twitter:description" content="Frequently asked questions"> ``` +If your site needs a custom Javascript library or CSS style you can override this file `layouts/partials/custom_headers.html` with the proper content like: + +```html +<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> +``` ## Usage diff --git a/layouts/404.html b/layouts/404.html index dffac47..4bea486 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> - {{ partial "head.html" . }} + <head> + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + </head> <body> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c0f7ea4..8a355f2 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> - {{ partial "head.html" . }} + <head> + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + </head> <body> diff --git a/layouts/_default/single.html b/layouts/_default/single.html index d5b5c6e..15956c5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> - {{ partial "head.html" . }} + <head> + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + </head> <body> diff --git a/layouts/index.html b/layouts/index.html index 43151ff..96209d4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> - {{ partial "head.html" . }} + <head> + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + </head> <body> diff --git a/layouts/page/single.html b/layouts/page/single.html index 28b4426..5e18140 100644 --- a/layouts/page/single.html +++ b/layouts/page/single.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> - {{ partial "head.html" . }} + <head> + {{ partial "headers.html" . }} + {{ partial "custom_headers.html" . }} + </head> <body> diff --git a/layouts/partials/custom_headers.html b/layouts/partials/custom_headers.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/partials/custom_headers.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html deleted file mode 100644 index a368d16..0000000 --- a/layouts/partials/head.html +++ /dev/null @@ -1,103 +0,0 @@ -<head> - <meta charset="utf-8"> - <meta name="robots" content="all,follow"> - <meta name="googlebot" content="index,follow,snippet,archive"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - {{ $title_plain := .Title | markdownify | plainify }} - <title>{{ $title_plain }}</title> - <meta name="author" content="{{ .Param "author" }}" /> - {{ $keywords := .Site.Params.defaultKeywords | default (slice "" | first 0) }} - {{ if isset .Params "tags" }}{{ range .Params.tags }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} - {{ if isset .Params "keywords" }}{{ range .Params.keywords }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} - {{ if gt (len $keywords) 0 }} - <meta name="keywords" content="{{ delimit (uniq $keywords) ", " }}"> - {{ end }} - {{ $description_plain := default .Site.Params.defaultDescription .Description | markdownify | plainify }} - <meta name="description" content="{{ $description_plain }}"> - - {{ hugo.Generator }} - - <!-- Font --> - <link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800' rel='stylesheet' type='text/css'> - - <!-- Bootstrap and Font Awesome CSS --> - <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.11.2/css/all.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> - - <!-- CSS animations --> - <link href="{{ "css/animate.css" | relURL}}" rel="stylesheet"> - - <!-- Theme stylesheet, if possible do not edit this stylesheet --> - {{ with .Site.Params.style }} - <link href="{{ "css/style" | relURL}}.{{ . }}.css" rel="stylesheet" id="theme-stylesheet"> - {{ else }} - <link href="{{ "css/style.default.css" | relURL}}" rel="stylesheet" id="theme-stylesheet"> - {{ end }} - - <!-- Custom stylesheet - for your changes --> - <link href="{{ "css/custom.css" | relURL}}" rel="stylesheet"> - - <!-- Responsivity for older IE --> - {{ ` - <!--[if lt IE 9]> - <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> - <![endif]--> - ` | safeHTML }} - - <!-- Favicon and Apple touch icons--> - <link rel="shortcut icon" href="{{ "img/favicon.ico" | relURL }}" type="image/x-icon" /> - <link rel="apple-touch-icon" href="{{ "img/apple-touch-icon.png" | relURL }}" /> - - <!-- owl carousel CSS --> - <link href="{{ "css/owl.carousel.css" | relURL}}" rel="stylesheet"> - <link href="{{ "css/owl.theme.css" | relURL}}" rel="stylesheet"> - - <!-- RSS feed --> - <link rel="alternate" href="{{ "/index.xml" | absURL }}" type="application/rss+xml" title="{{ .Site.Title }}"> - - <!-- Facebook OpenGraph tags --> - {{ $is_blog := and (eq .Type "blog") (eq .Kind "page") }} - {{ $has_image := isset .Params "banner" }} - {{ $image := cond $has_image .Params.banner (.Site.Params.default_sharing_image | default "img/sharing-default.png") }} - {{ $is_valid_image := print "static/" $image | fileExists }} - {{ if $is_valid_image }} - {{ $image_ext := path.Ext $image }} - <meta property="og:locale" content="{{ replace .Site.LanguageCode "-" "_" }}"> - <meta property="og:site_name" content="{{ .Site.Title }}"> - <meta property="og:title" content="{{ $title_plain }}"> - <meta property="og:type" content="{{ cond $is_blog "article" "website" }}"> - <meta property="og:url" content="{{ .Permalink }}" /> - <meta property="og:description" content="{{ $description_plain }}"> - <meta property="og:image" content="{{ $image | absURL }}"> - <meta property="og:image:type" content="image/{{ if eq $image_ext ".svg" }}svg+xml{{ else }}{{ trim $image_ext "." }}{{ end }}"> - {{ with .Params.banner_alt }}<meta property="og:image:alt" content="{{ . | markdownify | plainify }}">{{ end }} - {{ $image_local := printf "/static/%s" $image}} - {{ with (imageConfig $image_local) }} - <meta property="og:image:width" content="{{ .Width }}"> - <meta property="og:image:height" content="{{ .Height }}"> - {{ end }} - {{ end }} - {{ with .Lastmod }}<meta property="og:updated_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} - {{ if $is_blog }} - {{ with .Param "facebook_site" }}<meta property="article:publisher" content="https://www.facebook.com/{{ . }}/">{{ end }} - {{ with .Param "facebook_author" }}<meta property="article:author" content="https://www.facebook.com/{{ . }}/">{{ end }} - {{ with .Params.categories }}<meta property="article:section" content="{{ index . 0 }}">{{ end }} - {{ range .Params.tags }}<meta property="article:tag" content="{{ . }}"> - {{ end }} - {{ if gt .ExpiryDate .PublishDate }}<meta property="article:expiration_time" content="{{ .ExpiryDate.Format "2006-01-02T15:04:05Z0700" }}">{{ end }} - {{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} - {{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} - {{ end }} - - <!-- Twitter Card meta tags --> - <meta name="twitter:card" content="summary{{ if (and $is_blog (and $has_image $is_valid_image)) }}_large_image{{ end }}"> - {{ with .Param "twitter_site" }}<meta name="twitter:site" content="@{{ . }}">{{ end }} - <meta name="twitter:title" content="{{ $title_plain | truncate 70 }}"> - {{ if $is_valid_image }} - <meta name="twitter:image" content="{{ $image | absURL }}"> - {{ end }} - <meta name="twitter:description" content="{{ $description_plain | truncate 200 }}"> - {{ with .Param "twitter_author" }}<meta name="twitter:creator" content="@{{ . }}">{{ end }} - -</head> diff --git a/layouts/partials/headers.html b/layouts/partials/headers.html new file mode 100644 index 0000000..818adbb --- /dev/null +++ b/layouts/partials/headers.html @@ -0,0 +1,100 @@ +<meta charset="utf-8"> +<meta name="robots" content="all,follow"> +<meta name="googlebot" content="index,follow,snippet,archive"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +{{ $title_plain := .Title | markdownify | plainify }} +<title>{{ $title_plain }}</title> +<meta name="author" content="{{ .Param "author" }}" /> +{{ $keywords := .Site.Params.defaultKeywords | default (slice "" | first 0) }} +{{ if isset .Params "tags" }}{{ range .Params.tags }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} +{{ if isset .Params "keywords" }}{{ range .Params.keywords }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }} +{{ if gt (len $keywords) 0 }} +<meta name="keywords" content="{{ delimit (uniq $keywords) ", " }}"> +{{ end }} +{{ $description_plain := default .Site.Params.defaultDescription .Description | markdownify | plainify }} +<meta name="description" content="{{ $description_plain }}"> + +{{ hugo.Generator }} + +<!-- Font --> +<link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800' rel='stylesheet' type='text/css'> + +<!-- Bootstrap and Font Awesome CSS --> +<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.11.2/css/all.css"> +<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> + +<!-- CSS animations --> +<link href="{{ "css/animate.css" | relURL}}" rel="stylesheet"> + +<!-- Theme stylesheet, if possible do not edit this stylesheet --> +{{ with .Site.Params.style }} + <link href="{{ "css/style" | relURL}}.{{ . }}.css" rel="stylesheet" id="theme-stylesheet"> +{{ else }} + <link href="{{ "css/style.default.css" | relURL}}" rel="stylesheet" id="theme-stylesheet"> +{{ end }} + +<!-- Custom stylesheet - for your changes --> +<link href="{{ "css/custom.css" | relURL}}" rel="stylesheet"> + +<!-- Responsivity for older IE --> +{{ ` + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> +` | safeHTML }} + +<!-- Favicon and Apple touch icons--> +<link rel="shortcut icon" href="{{ "img/favicon.ico" | relURL }}" type="image/x-icon" /> +<link rel="apple-touch-icon" href="{{ "img/apple-touch-icon.png" | relURL }}" /> + +<!-- owl carousel CSS --> +<link href="{{ "css/owl.carousel.css" | relURL}}" rel="stylesheet"> +<link href="{{ "css/owl.theme.css" | relURL}}" rel="stylesheet"> + +<!-- RSS feed --> +<link rel="alternate" href="{{ "/index.xml" | absURL }}" type="application/rss+xml" title="{{ .Site.Title }}"> + +<!-- Facebook OpenGraph tags --> +{{ $is_blog := and (eq .Type "blog") (eq .Kind "page") }} +{{ $has_image := isset .Params "banner" }} +{{ $image := cond $has_image .Params.banner (.Site.Params.default_sharing_image | default "img/sharing-default.png") }} +{{ $is_valid_image := print "static/" $image | fileExists }} +{{ if $is_valid_image }} +{{ $image_ext := path.Ext $image }} +<meta property="og:locale" content="{{ replace .Site.LanguageCode "-" "_" }}"> +<meta property="og:site_name" content="{{ .Site.Title }}"> +<meta property="og:title" content="{{ $title_plain }}"> +<meta property="og:type" content="{{ cond $is_blog "article" "website" }}"> +<meta property="og:url" content="{{ .Permalink }}" /> +<meta property="og:description" content="{{ $description_plain }}"> +<meta property="og:image" content="{{ $image | absURL }}"> +<meta property="og:image:type" content="image/{{ if eq $image_ext ".svg" }}svg+xml{{ else }}{{ trim $image_ext "." }}{{ end }}"> +{{ with .Params.banner_alt }}<meta property="og:image:alt" content="{{ . | markdownify | plainify }}">{{ end }} +{{ $image_local := printf "/static/%s" $image}} +{{ with (imageConfig $image_local) }} + <meta property="og:image:width" content="{{ .Width }}"> + <meta property="og:image:height" content="{{ .Height }}"> +{{ end }} +{{ end }} +{{ with .Lastmod }}<meta property="og:updated_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} +{{ if $is_blog }} + {{ with .Param "facebook_site" }}<meta property="article:publisher" content="https://www.facebook.com/{{ . }}/">{{ end }} + {{ with .Param "facebook_author" }}<meta property="article:author" content="https://www.facebook.com/{{ . }}/">{{ end }} + {{ with .Params.categories }}<meta property="article:section" content="{{ index . 0 }}">{{ end }} + {{ range .Params.tags }}<meta property="article:tag" content="{{ . }}"> + {{ end }} + {{ if gt .ExpiryDate .PublishDate }}<meta property="article:expiration_time" content="{{ .ExpiryDate.Format "2006-01-02T15:04:05Z0700" }}">{{ end }} + {{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} + {{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }} +{{ end }} + +<!-- Twitter Card meta tags --> +<meta name="twitter:card" content="summary{{ if (and $is_blog (and $has_image $is_valid_image)) }}_large_image{{ end }}"> +{{ with .Param "twitter_site" }}<meta name="twitter:site" content="@{{ . }}">{{ end }} +<meta name="twitter:title" content="{{ $title_plain | truncate 70 }}"> +{{ if $is_valid_image }} +<meta name="twitter:image" content="{{ $image | absURL }}"> +{{ end }} +<meta name="twitter:description" content="{{ $description_plain | truncate 200 }}"> +{{ with .Param "twitter_author" }}<meta name="twitter:creator" content="@{{ . }}">{{ end }} diff --git a/static/css/custom.css b/static/css/custom.css index d62cd94..a745873 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,5 +1,3 @@ -/* your styles go here */ - .box-image-text .image { min-height: 190px; max-height: 190px; |