Skip to content

Commit da6c71b

Browse files
authored
Allow to add third party javascript or css libraries. (#240)
* Allow to add third party javascript or css libraries. * Added missing places. * Update custom_headers.html * Added header. * Updated readme. * Removed comment.
1 parent 38f4944 commit da6c71b

10 files changed

Lines changed: 127 additions & 111 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ style = "default"
9494
```
9595

9696
Available options are: `default` (light-blue), `blue`, `green`, `marsala`, `pink`, `red`, `turquoise`, `violet`.
97+
There is the possibility to override the CSS and set your custom styles, override this file `static/css/custom.css` in your site.
9798

9899

99100
### Comments
@@ -529,7 +530,7 @@ summaryLength = 70
529530
[params.recent_posts]
530531
enable = true
531532
title = "From our blog"
532-
subtitle = "Pellen
533+
subtitle = "Pellen"
533534
hide_summary = false
534535
```
535536

@@ -641,6 +642,11 @@ Which results in the following HTML:
641642
<meta name="twitter:description" content="Frequently asked questions">
642643
```
643644

645+
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:
646+
647+
```html
648+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
649+
```
644650

645651
## Usage
646652

layouts/404.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
{{ partial "head.html" . }}
4+
<head>
5+
{{ partial "headers.html" . }}
6+
{{ partial "custom_headers.html" . }}
7+
</head>
58

69
<body>
710

layouts/_default/list.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
{{ partial "head.html" . }}
4+
<head>
5+
{{ partial "headers.html" . }}
6+
{{ partial "custom_headers.html" . }}
7+
</head>
58

69
<body>
710

layouts/_default/single.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
{{ partial "head.html" . }}
4+
<head>
5+
{{ partial "headers.html" . }}
6+
{{ partial "custom_headers.html" . }}
7+
</head>
58

69
<body>
710

layouts/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
{{ partial "head.html" . }}
4+
<head>
5+
{{ partial "headers.html" . }}
6+
{{ partial "custom_headers.html" . }}
7+
</head>
58

69
<body>
710

layouts/page/single.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
{{ partial "head.html" . }}
4+
<head>
5+
{{ partial "headers.html" . }}
6+
{{ partial "custom_headers.html" . }}
7+
</head>
58

69
<body>
710

layouts/partials/custom_headers.html

Whitespace-only changes.

layouts/partials/head.html

Lines changed: 0 additions & 103 deletions
This file was deleted.

layouts/partials/headers.html

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<meta charset="utf-8">
2+
<meta name="robots" content="all,follow">
3+
<meta name="googlebot" content="index,follow,snippet,archive">
4+
<meta name="viewport" content="width=device-width, initial-scale=1">
5+
{{ $title_plain := .Title | markdownify | plainify }}
6+
<title>{{ $title_plain }}</title>
7+
<meta name="author" content="{{ .Param "author" }}" />
8+
{{ $keywords := .Site.Params.defaultKeywords | default (slice "" | first 0) }}
9+
{{ if isset .Params "tags" }}{{ range .Params.tags }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }}
10+
{{ if isset .Params "keywords" }}{{ range .Params.keywords }}{{ $keywords = $keywords | append . }}{{ end }}{{ end }}
11+
{{ if gt (len $keywords) 0 }}
12+
<meta name="keywords" content="{{ delimit (uniq $keywords) ", " }}">
13+
{{ end }}
14+
{{ $description_plain := default .Site.Params.defaultDescription .Description | markdownify | plainify }}
15+
<meta name="description" content="{{ $description_plain }}">
16+
17+
{{ hugo.Generator }}
18+
19+
<!-- Font -->
20+
<link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800' rel='stylesheet' type='text/css'>
21+
22+
<!-- Bootstrap and Font Awesome CSS -->
23+
<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.11.2/css/all.css">
24+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
25+
26+
<!-- CSS animations -->
27+
<link href="{{ "css/animate.css" | relURL}}" rel="stylesheet">
28+
29+
<!-- Theme stylesheet, if possible do not edit this stylesheet -->
30+
{{ with .Site.Params.style }}
31+
<link href="{{ "css/style" | relURL}}.{{ . }}.css" rel="stylesheet" id="theme-stylesheet">
32+
{{ else }}
33+
<link href="{{ "css/style.default.css" | relURL}}" rel="stylesheet" id="theme-stylesheet">
34+
{{ end }}
35+
36+
<!-- Custom stylesheet - for your changes -->
37+
<link href="{{ "css/custom.css" | relURL}}" rel="stylesheet">
38+
39+
<!-- Responsivity for older IE -->
40+
{{ `
41+
<!--[if lt IE 9]>
42+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
43+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
44+
<![endif]-->
45+
` | safeHTML }}
46+
47+
<!-- Favicon and Apple touch icons-->
48+
<link rel="shortcut icon" href="{{ "img/favicon.ico" | relURL }}" type="image/x-icon" />
49+
<link rel="apple-touch-icon" href="{{ "img/apple-touch-icon.png" | relURL }}" />
50+
51+
<!-- owl carousel CSS -->
52+
<link href="{{ "css/owl.carousel.css" | relURL}}" rel="stylesheet">
53+
<link href="{{ "css/owl.theme.css" | relURL}}" rel="stylesheet">
54+
55+
<!-- RSS feed -->
56+
<link rel="alternate" href="{{ "/index.xml" | absURL }}" type="application/rss+xml" title="{{ .Site.Title }}">
57+
58+
<!-- Facebook OpenGraph tags -->
59+
{{ $is_blog := and (eq .Type "blog") (eq .Kind "page") }}
60+
{{ $has_image := isset .Params "banner" }}
61+
{{ $image := cond $has_image .Params.banner (.Site.Params.default_sharing_image | default "img/sharing-default.png") }}
62+
{{ $is_valid_image := print "static/" $image | fileExists }}
63+
{{ if $is_valid_image }}
64+
{{ $image_ext := path.Ext $image }}
65+
<meta property="og:locale" content="{{ replace .Site.LanguageCode "-" "_" }}">
66+
<meta property="og:site_name" content="{{ .Site.Title }}">
67+
<meta property="og:title" content="{{ $title_plain }}">
68+
<meta property="og:type" content="{{ cond $is_blog "article" "website" }}">
69+
<meta property="og:url" content="{{ .Permalink }}" />
70+
<meta property="og:description" content="{{ $description_plain }}">
71+
<meta property="og:image" content="{{ $image | absURL }}">
72+
<meta property="og:image:type" content="image/{{ if eq $image_ext ".svg" }}svg+xml{{ else }}{{ trim $image_ext "." }}{{ end }}">
73+
{{ with .Params.banner_alt }}<meta property="og:image:alt" content="{{ . | markdownify | plainify }}">{{ end }}
74+
{{ $image_local := printf "/static/%s" $image}}
75+
{{ with (imageConfig $image_local) }}
76+
<meta property="og:image:width" content="{{ .Width }}">
77+
<meta property="og:image:height" content="{{ .Height }}">
78+
{{ end }}
79+
{{ end }}
80+
{{ with .Lastmod }}<meta property="og:updated_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }}
81+
{{ if $is_blog }}
82+
{{ with .Param "facebook_site" }}<meta property="article:publisher" content="https://www.facebook.com/{{ . }}/">{{ end }}
83+
{{ with .Param "facebook_author" }}<meta property="article:author" content="https://www.facebook.com/{{ . }}/">{{ end }}
84+
{{ with .Params.categories }}<meta property="article:section" content="{{ index . 0 }}">{{ end }}
85+
{{ range .Params.tags }}<meta property="article:tag" content="{{ . }}">
86+
{{ end }}
87+
{{ if gt .ExpiryDate .PublishDate }}<meta property="article:expiration_time" content="{{ .ExpiryDate.Format "2006-01-02T15:04:05Z0700" }}">{{ end }}
88+
{{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }}
89+
{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z0700" }}">{{ end }}
90+
{{ end }}
91+
92+
<!-- Twitter Card meta tags -->
93+
<meta name="twitter:card" content="summary{{ if (and $is_blog (and $has_image $is_valid_image)) }}_large_image{{ end }}">
94+
{{ with .Param "twitter_site" }}<meta name="twitter:site" content="@{{ . }}">{{ end }}
95+
<meta name="twitter:title" content="{{ $title_plain | truncate 70 }}">
96+
{{ if $is_valid_image }}
97+
<meta name="twitter:image" content="{{ $image | absURL }}">
98+
{{ end }}
99+
<meta name="twitter:description" content="{{ $description_plain | truncate 200 }}">
100+
{{ with .Param "twitter_author" }}<meta name="twitter:creator" content="@{{ . }}">{{ end }}

static/css/custom.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* your styles go here */
2-
31
.box-image-text .image {
42
min-height: 190px;
53
max-height: 190px;

0 commit comments

Comments
 (0)