Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 3f55fc1

Browse files
committed
Add OpenGraph metadata
1 parent 5838ad6 commit 3f55fc1

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ title: nais blog
44
theme: naisblog
55
markup:
66
highlight:
7-
style: dracula
8-
7+
style: dracula

content/posts/otel-from-0-to-100.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ date: 2024-05-17T19:09:09+02:00
55
draft: false
66
author: Hans Kristian Flaatten
77
tags: [observability, tracing, opentelemetry, tempo, grafana]
8+
featuredImage: /blog/images/otel-rappids-and-rivers.png
89
---
910

1011
This is the story of how we adopted [OpenTelemetry][otel] at the Norwegian Labour and Welfare Administration (NAV). We will cover the journey from the first steps to the first traces in production. We will also share some of the challenges we faced and how we overcame them.

themes/naisblog/layouts/partials/head.html

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
<title>{{ .Site.Title }}</title>
1616

1717
<script type="text/javascript" src="/blog/amplitude.js"></script>
18+
{{- partial "opengraph.html" . -}}
1819
</head>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<meta property="og:title" content="{{ .Title }}">
2+
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
3+
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
4+
{{ $href := .Permalink }}
5+
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
6+
<meta property="og:url" content="{{ $href }}">
7+
<meta property="og:locale" content="{{ .Site.LanguageCode }}">
8+
9+
{{ if .Params.featuredImage }}
10+
<meta property="og:image" content="{{ .Params.featuredImage | absURL }}">
11+
{{ else if .Site.Params.og_image }}
12+
<meta property="og:image" content="{{.Site.BaseURL}}{{ .Site.Params.og_image }}"> <!-- use 1.91:1 minimum 1200x630 -->
13+
{{ end }}
14+
15+
{{ if (findRE `(?s)<img.+?>` .Content) }}{{ range $k, $_ := findRE `(?s)<img.+?>` .Content }}{{ if $k }}{{ end }}
16+
<meta property="og:image" content="{{ replaceRE `(?s).*src="(.+?)".*` "$1" . | absURL }}">
17+
{{ end }}{{ end }}
18+
19+
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
20+
{{- if .IsPage }}
21+
22+
{{- if not .PublishDate.IsZero }}<meta property="article:published_time" {{ .PublishDate.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
23+
{{ else if not .Date.IsZero }}<meta property="article:published_time" {{ .Date.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
24+
{{ end }}
25+
26+
{{- if not .Lastmod.IsZero }}<meta property="article:modified_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
27+
<meta property="og:updated_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>{{ else }}<meta property="og:updated_time" {{ .Date.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
28+
{{- end }}
29+
30+
{{- end }}{{/* .IsPage */}}
31+
32+
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}">{{ end }}
33+
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}">{{ end }}
34+
{{- with .Params.videos }}
35+
{{- range . }}
36+
<meta property="og:video" content="{{ . | absURL }}">
37+
{{ end }}{{ end }}
38+
39+
{{- /* If it is part of a series, link to related articles */}}
40+
{{- $permalink := .Permalink }}
41+
{{- $siteSeries := .Site.Taxonomies.series }}{{ with .Params.series }}
42+
{{- range $name := . }}
43+
{{- $series := index $siteSeries ($name | urlize) }}
44+
{{- range $page := first 6 $series.Pages }}
45+
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}">{{ end }}
46+
{{- end }}
47+
{{ end }}{{ end }}
48+
49+
{{- if .IsPage }}
50+
{{ with .Site.Author.facebook }}<meta property="article:author" content="https://www.facebook.com/{{ . }}">{{ end }}
51+
{{ with .Site.Social.facebook }}<meta property="article:publisher" content="https://www.facebook.com/{{ . }}">{{ end }}
52+
{{ with .GetTerms "categories"}}{{ range first 1 . }}<meta property="article:section" content="{{ .LinkTitle | lower }}">
53+
{{ end }}{{ end }}
54+
{{- with .GetTerms "tags" }}{{ range . }}<meta property="article:tag" content="{{ .LinkTitle | lower }}">
55+
{{ end }}{{ end }}
56+
{{ end }}
57+
58+
{{- /* Facebook Page Admin ID for Domain Insights */}}
59+
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}">{{ end }}

0 commit comments

Comments
 (0)