diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index f2820a7..9a0ecca 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -4,24 +4,26 @@
{{- $u := urls.Parse $destination -}}
{{- if not $u.Scheme -}}
- {{- with site.GetPage .Destination -}}
- {{- $backlinks := .Store.Get "backlinks" | default slice -}}
+ {{- $page := site.GetPage $destination -}}
+ {{- if $page -}}
+ {{- $backlinks := $page.Store.Get "backlinks" | default slice -}}
{{- $backlinks := $backlinks|append $currentPage.RelPermalink -}}
- {{- .Store.Set "backlinks" ($backlinks|uniq) -}}
+ {{- $page.Store.Set "backlinks" ($backlinks|uniq) -}}
{{- if not $text -}}
- {{- $text = .LinkTitle -}}
+ {{- $text = $page.LinkTitle -}}
{{- end -}}
- {{- .Section -}}⁄{{- $text -}}
- {{- end -}}
- {{- if hasPrefix $destination "/library" -}}
+ {{- $page.Section -}}⁄{{- $text -}}
+ {{- else if hasPrefix $destination "/library" -}}
{{- $bib := strings.TrimPrefix "/library/" $destination -}}
{{- $b := index site.Data.books.catalog $bib -}}
{{- if not $text -}}
{{- $text = $b.title|default "" -}}
{{- end -}}
library⁄{{- $text -}}
+ {{- else -}}
+ {{- warnf "In %s broken link: %s" $currentPage.RelPermalink $destination -}}
{{- end -}}
{{- else -}}
- www⁄{{- with .Text }}{{ . }}{{- end -}}
+ www⁄{{- if .Text }}{{ .Text }}{{- else -}}{{- .Destination -}}{{- end -}}
{{- end -}}
{{- /* chomp trailing newline */ -}}