diff --git a/layouts/_partials/lang-detection.html b/layouts/_partials/lang-detection.html
index 46c2f6b..d568ef8 100644
--- a/layouts/_partials/lang-detection.html
+++ b/layouts/_partials/lang-detection.html
@@ -1,15 +1,22 @@
-{{ if and .IsPage .IsTranslated (eq .Lang "fr") }}
-
- {{ if and (index .AllTranslations 0).File (index .AllTranslations 1).File }}
- {{ $file0 := readFile (index .AllTranslations 0).File.Filename }}
- {{ $file1 := readFile (index .AllTranslations 1).File.Filename }}
- {{ if eq (sha256 $file0) (sha256 $file1) }}
- {{ .Store.Set "en_article_in_fr_site" true }}
- {{ end }}
- {{ else }}
-
- {{ if eq (index .AllTranslations 0).Plain (index .AllTranslations 1).Plain }}
- {{ .Store.Set "en_article_in_fr_site" true }}
- {{ end }}
- {{ end }}
-{{ end }}
+{{- /*
+ -- Detects the english articles published as-is in the french site and
+ -- sets "en_article_in_fr_site" in the page store.
+ --
+ -- This partial must not output anything since it is also called from
+ -- inline contexts (internalLink shortcode, article headlines).
+ */ -}}
+{{- if and .IsPage .IsTranslated (eq .Lang "fr") -}}
+ {{- if and (index .AllTranslations 0).File (index .AllTranslations 1).File -}}
+ {{- /* Try to compare files by SHA256 fingerprint. */ -}}
+ {{- $file0 := readFile (index .AllTranslations 0).File.Filename -}}
+ {{- $file1 := readFile (index .AllTranslations 1).File.Filename -}}
+ {{- if eq (sha256 $file0) (sha256 $file1) -}}
+ {{- .Store.Set "en_article_in_fr_site" true -}}
+ {{- end -}}
+ {{- else -}}
+ {{- /* Sometimes there is no file though. In that case, compare the content. */ -}}
+ {{- if eq (index .AllTranslations 0).Plain (index .AllTranslations 1).Plain -}}
+ {{- .Store.Set "en_article_in_fr_site" true -}}
+ {{- end -}}
+ {{- end -}}
+{{- end -}}
diff --git a/layouts/_shortcodes/internalLink.html b/layouts/_shortcodes/internalLink.html
index b250916..1af471b 100644
--- a/layouts/_shortcodes/internalLink.html
+++ b/layouts/_shortcodes/internalLink.html
@@ -1,31 +1,26 @@
-
-{{ $path := .Get "path" }}
-{{ $currentLang := .Page.Lang }}
-{{ $title := .Get "title" }}
-{{ $sites := hugo.Sites }}
-{{ if ne $currentLang (index hugo.Sites 0).Language.Lang }}
-{{ $sites = collections.Reverse hugo.Sites }}
-{{ end }}
-{{ range $sites }}
-{{ with .GetPage $path }}
-
-{{ if ne $title "" }}
-{{ $title }}
-{{ else }}
-{{ .Title }}
-{{ end }}
-
-{{ if and (eq $currentLang "en") (eq .Lang "fr") }}
-{{- partial "icons/fr.svg" . -}}
-{{ end }}
-{{ if (eq $currentLang "fr") }}
+ -- Currently, this shortcode can only handle Hugo sites with two languages.
+ --
+ -- The output must not contain any extra whitespace since the link is
+ -- usually embedded in a sentence.
+ */ -}}
+{{- $path := .Get "path" -}}
+{{- $currentLang := .Page.Lang -}}
+{{- $title := .Get "title" -}}
+{{- $sites := hugo.Sites -}}
+{{- if ne $currentLang (index hugo.Sites 0).Language.Lang -}}
+{{- $sites = collections.Reverse hugo.Sites -}}
+{{- end -}}
+{{- range $sites -}}
+{{- with .GetPage $path -}}
+{{ or $title .Title }}
+{{- if and (eq $currentLang "en") (eq .Lang "fr") }} {{ partial "icons/fr.svg" . | strings.TrimSpace | safeHTML }}{{ end -}}
+{{- if eq $currentLang "fr" -}}
{{- partial "lang-detection.html" . -}}
-{{ if .Store.Get "en_article_in_fr_site" }}
-{{- partial "icons/en.svg" . -}}
-{{ end }}
-{{ end }}
-{{ break }}
-{{ end }}
-{{ end }}
+{{- if .Store.Get "en_article_in_fr_site" }} {{ partial "icons/en.svg" . | strings.TrimSpace | safeHTML }}{{ end -}}
+{{- end -}}
+{{- break -}}
+{{- end -}}
+{{- end -}}