Skip to content

Commit

Permalink
feat: Add canonical URL to blog posts
Browse files Browse the repository at this point in the history
Used some code from PaperMod
  • Loading branch information
slashtechno committed Jun 1, 2024
1 parent e334587 commit e7193e7
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 15 deletions.
1 change: 1 addition & 0 deletions content/blog/2022/my-experience-with-gh-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ draft: false
# tags: ["github", "software"]
params:
description: I've started using Github Actions. This is my experience with it, and how I setup a Go CI workflow
canonicalURL: "https://angad.me/blog/2022/my-experience-with-gh-actions/"
---
I started using Github Actions a couple months ago. While I'm not a power user of Github Actions, I still find it to be powerful.
### What is Github Actions?
Expand Down
4 changes: 2 additions & 2 deletions content/blog/2023/setting-up-synapse.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Self-hosting a Matrix Server With Synapse
date: 2023-09-02
# summary:
draft: false
# tags: ["github", "software"]
params:
canonicalURL: "https://angad.me/blog/2023/setting-up-synapse/"
description: Running Synapse in Docker to self-host a Matrix instance
---
Matrix is a versatile protocol for communication. Similar to ActivityPub, which Mastodon uses, Matrix supports federation. Thus, by self-hosting, you're using your own server whilst also being able to use your own domain.
Expand Down
11 changes: 0 additions & 11 deletions content/blog/2024/introducing-llmail.md

This file was deleted.

5 changes: 3 additions & 2 deletions content/blog/2024/synapse-signal-bridge.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Simple Signal-Matrix Bridge in Docker
date: 2024-02-03
# summary:
draft: false
# tags: ["signal", "matrix"]
description: Setting up a (simple) bridge between Matrix and Signal
params:
canonicalURL: "https://angad.me/blog/2024/synapse-signal-bridge/"

---
## A short introduction
In September of 2023, I wrote a [post](/blog/2023/setting-up-synapse/) regarding the setup of a simple Matrix server. Personally, I think that Matrix is a cool protocol, but I don't use it much (at the time of writing). However, I love the ability to bridge chat services. Beeper, the company which has recently been in the news for developing a native Android iMessage client, originally started out bridging chat services. Whilst their service itself is proprietary (at the time of writing), the bridges they use are open source. They even have a [guide](https://github.com/beeper/self-host) on how to self-host various bridges and Matrix with Ansible. I have not gotten around to learning Ansible so I manually set up various Docker containers which allows for a similar result.
Expand Down
16 changes: 16 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ define "main" }}
<article class="mt-10 flex flex-col items-center justify-center">
<nav class="place-self-start">
<a href="{{ "" | relURL }}" class="text-neutral-500">&larr; {{ i18n "nav.home" }}</a>
</nav>
<header>
<h1 class="mb-6 mt-2 text-center text-4xl font-extrabold text-neutral-800 dark:text-white">
{{ .Title | emojify }}
</h1>
<h3>{{- partial "post_canonical.html" . -}}</h3>
</header>
<section class="prose dark:prose-invert">
{{ .Content | emojify }}
</section>
</article>
{{ end }}
92 changes: 92 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<head>
<meta charset="utf-8" />
{{ with .Site.LanguageCode }}
<meta http-equiv="content-language" content="{{ . }}" />
{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
{{/* Title */}}
{{ if .IsHome -}}
<title>{{ .Site.Title }}</title>
<meta name="title" content="{{ .Site.Title }}" />
{{- else -}}
<title>{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}</title>
<meta name="title" content="{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}" />
{{- end }}
{{/* Metadata */}}
{{ with .Params.Description -}}
<meta name="description" content="{{ . }}" />
{{- else -}}
<meta name="description" content="{{ $.Site.Params.Description }}" />
{{- end }}
{{ with .Site.Params.keywords -}}
<meta name="keywords" content="{{ . }}" />
{{- end }}
{{ with .Site.Params.robots }}
<meta name="robots" content="{{ . }}" />
{{ end }}
{{ with .Params.robots }}
<meta name="robots" content="{{ . }}" />
{{ end }}
<link rel="canonical" href="{{ if .Params.canonicalURL -}} {{ trim .Params.canonicalURL " " }} {{- else -}} {{ .Permalink }} {{- end }}">
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
{{ end -}}
{{/* Asset bundles */}}
{{ $assets := newScratch }}
{{ $cssMain := resources.Get "css/compiled/main.css" }}
{{ $assets.Add "css" (slice $cssMain) }}
{{ $cssCustom := resources.Get "css/custom.css" }}
{{ if $cssCustom }}
{{ $assets.Add "css" (slice $cssCustom) }}
{{ end }}
{{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint "sha512" }}
<link
type="text/css"
rel="stylesheet"
href="{{ $bundleCSS.RelPermalink }}"
integrity="{{ $bundleCSS.Data.Integrity }}"
/>
{{/* Icons */}}
{{ if templates.Exists "partials/favicons.html" }}
{{ partialCached "favicons.html" .Site }}
{{ else }}
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}" />
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}" />
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}" />
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}" />
{{ end }}
{{/* Site Verification */}}
{{ with .Site.Params.verification.google }}
<meta name="google-site-verification" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.verification.bing }}
<meta name="msvalidate.01" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.verification.pinterest }}
<meta name="p:domain_verify" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.verification.yandex }}
<meta name="yandex-verification" content="{{ . }}" />
{{ end }}
{{/* Social */}}
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{/* Generator */}}
{{ if .Site.Params.attribution | default true }}
{{ hugo.Generator }}
{{ end }}
{{/* Me */}}
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}" />{{ end }}
{{ with .Site.Author.links }}
{{ range $links := . }}
{{ range $name, $url := $links }}<link href="{{ $url }}" rel="me" />{{ end }}
{{ end }}
{{ end }}
{{/* Analytics */}}
{{ partialCached "analytics.html" . }}
{{/* Extend head - eg. for custom analytics scripts, etc. */}}
{{ if templates.Exists "partials/extend-head.html" }}
{{ partialCached "extend-head.html" .Site }}
{{ end }}
</head>
8 changes: 8 additions & 0 deletions layouts/partials/post_canonical.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- https://github.com/adityatelange/hugo-PaperMod/blob/3f50861a0ced88f9b614a43662edeb4c0bc45da8/layouts/partials/post_canonical.html -->
{{ if .Params.canonicalURL -}}
{{ $url := urls.Parse .Params.canonicalURL }}
<span>
{{- (site.Params.CanonicalLinkText | default .Params.CanonicalLinkText) | default "Originally published at" -}}
&nbsp;<a href="{{ trim .Params.canonicalURL " " }}" title="{{ trim .Params.canonicalURL " " }}" target="_blank" rel="noopener noreferrer" style="text-decoration: underline;">{{ $url.Host }}</a>
</span>
{{- end }}

0 comments on commit e7193e7

Please sign in to comment.