Skip to content

Commit 0da1eca

Browse files
committed
refactor(head): create head partial for improved HTML structure
Refactored the base HTML layout by moving the head section into a new partial file.
1 parent d6db185 commit 0da1eca

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

layouts/_default/baseof.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.Language.Lang }}">
3-
<head>
4-
{{ partial "analytics.html" . }}
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>{{ .Title }}</title>
8-
{{ $styles := resources.Get "css/main.css" | minify }}
9-
<link rel="stylesheet" href="{{ $styles.RelPermalink }}">
10-
{{ $js := resources.Get "js/main.js" | minify }}
11-
<script src="{{ $js.RelPermalink }}" defer></script>
12-
<!-- Font Awesome for icons -->
13-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
14-
<!-- Google Fonts -->
15-
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
16-
</head>
3+
{{ partial "head.html" . }}
174
<body class="light-mode">
185
<header class="navbar">
196
{{ partial "navbar.html" . }}

layouts/partials/head.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{ $img := resources.Get .Site.Params.profilePicture }}
2+
<head>
3+
{{ partial "analytics.html" . }}
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>{{ .Title }}</title>
7+
8+
<!-- SEO Meta Tags -->
9+
<meta name="description" content="{{ .Description | default .Summary | plainify}}">
10+
{{ if .Keywords }}
11+
<meta name="keywords" content="{{ delimit .Keywords ", " }}">
12+
{{ end }}
13+
<meta name="author" content="{{ .Site.Params.author }}">
14+
15+
<!-- Open Graph / Facebook -->
16+
<meta property="og:type" content="website">
17+
<meta property="og:url" content="{{ .Permalink }}">
18+
<meta property="og:title" content="{{ .Title }}">
19+
<meta property="og:description" content="{{ .Description | default .Summary | plainify}}">
20+
<meta property="og:image" content="{{ if .Params.image }}{{ .Params.image | absURL }}{{ else }}{{ $img.RelPermalink }}{{ end }}">
21+
22+
<!-- Twitter -->
23+
<meta name="twitter:card" content="summary_large_image">
24+
<meta name="twitter:title" content="{{ .Title }}">
25+
<meta name="twitter:description" content="{{ .Description | default .Summary | plainify}}">
26+
<meta name="twitter:image" content="{{ if .Params.image }}{{ .Params.image | absURL }}{{ else }}{{ $img.RelPermalink }}{{ end }}">
27+
28+
<!-- Canonical URL -->
29+
<link rel="canonical" href="{{ .Permalink }}">
30+
31+
<!-- Favicon -->
32+
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.favicon | default "/favicon.ico" | relURL }}">
33+
34+
{{ $styles := resources.Get "css/main.css" | minify }}
35+
<link rel="stylesheet" href="{{ $styles.RelPermalink }}">
36+
{{ $js := resources.Get "js/main.js" | minify }}
37+
<script src="{{ $js.RelPermalink }}" defer></script>
38+
<!-- Font Awesome for icons -->
39+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
40+
<!-- Google Fonts -->
41+
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
42+
</head>

0 commit comments

Comments
 (0)