inspired by: https://github.com/milafrerichs/hugo-wikilinks

copy relevant files from your template into matching folder

cp themes/PaperMod/layouts/_default/single.html layouts/_default/single.html

cp themes/PaperMod/layouts/_default/list.html layouts/_default/list.html

change content rendering to use the wikilinks partial old: single.html

...
{{- if .Content }}  
<div class="post-content">  
  {{- if not (.Param "disableAnchoredHeadings") }}  
  {{- partial "anchored_headings.html" .Content -}}  
  {{- else }}{{ .Content }}{{ end }}  
</div>  
{{- end }}
...

new: single.html

...
{{- if .Content }}  
<div class="post-content">  
  {{- if in .Params.tags "clipping" }}  
  <p>source: <a href="{{ .Params.source }}">{{ .Params.source }}</a></p>  
  {{- else if .Draft }}  
  <p>coming soon...</p>  
  {{- else }}  
  {{ partial "content-wikilinks.gohtml" . }}  
  {{- end }}  
  {{ partial "content-backlinks.gohtml" . | markdownify }}  
</div>  
{{- end }}
...

old: list.html

<div class="entry-content">  
  <p>{{ .Summary | plainify | htmlUnescape }}{{ if .Truncated }}...{{ end }}</p>  
</div>

new list.html:

<div class="entry-content">  
    <p>{{ partial "funcs/strip-wikilinks.gohtml" (.Summary | plainify | htmlUnescape) }}{{ if .Truncated }}...{{ end }}</p>  
</div>

change obsidian wikilinks to hugo internal references

layouts/partials/content-wikilinks.gohtml

{{/*              [[  ( 1-file )(2|( 3-title))?  ]]   */}}  
{{ $wikiregex := `\[\[([^|\]]+)(\|([^|\]]+))?\]\]` }}  
{{ $page := .Page }}  
{{ $dot := . }}  
  
{{ $wikilinks := findRESubmatch $wikiregex .RawContent }}  
  
{{ $.Scratch.Add "content" .RawContent }}  
  
{{ range $wikilinks }}  
  
    {{ $fullMatch := index . 0 }}  
    {{ $wikiref := index . 1 }}  
    {{ $wikititle := index . 3 }}  
  
    {{ if strings.Contains $wikiref `/resources` }}  
        {{/*images etc*/}}  
        {{ $wikititle = $wikiref }}  
        {{ $wikiref = substr $wikiref 1 }}  
    {{ else }}  
        {{/*link to other page*/}}  
        {{ with $page.GetPage $wikiref }}  
            {{ $wikititle = .LinkTitle }}  
            {{ $wikiref = .RelPermalink }}  
        {{ else }}  
            {{ $wikiref = relref $dot $wikiref }}  
			{{ if eq $wikiref `/404.html` }}  
			    {{ continue }}  
			{{ end }}
        {{ end }}  
    {{ end }}  
  
    {{ if not $wikititle }}  
        {{ $wikititle = index . 1 }}  
    {{ end }}  
  
    {{ $link := printf "%s%s%s%s%s" "[" $wikititle "](" $wikiref ")" }}  
  
    {{/*<!--<p> replace {{ $fullMatch }} {{ $link }}</p>-->*/}}  
    {{ $noteContent := replace ($.Scratch.Get "content") $fullMatch $link }}  
    {{ $.Scratch.Set "content" $noteContent }}  
{{ end }}  
  
{{ $content := .Scratch.Get "content" }}  
{{ $content | markdownify}}

layouts/partials/funcs/strip-wikilinks.gohtml

used to strip wikilinks from summary texts

{{ $wikiregex := `!?\[\[([^|\]]+)(\|([^|\]]+))?\]\]` }}  
{{ $dot := . }}  
{{ $wikilinks := findRESubmatch $wikiregex $dot }}  
  
{{/*{{ $prefix := printf "%s%d%s" "wikilinks=" (len $wikilinks) " --- " }}*/}}  
  
{{ range $wikilinks }}  
    {{ $fullMatch := index . 0 }}  
    {{ $wikititle := index . 3 }}  
  
    {{/*    {{ $prefix = printf "%s%s%s%s" $prefix "fullmatch=" ($fullMatch) " --- " }}*/}}  
    {{ $dot = replace $dot $fullMatch $wikititle }}  
    {{/*    {{ $prefix = printf "%s%s%s%s" $prefix "tmp=" ($dot) " --- " }}*/}}  
  
{{ end }}  
{{/*{{ $dot = printf "%s%s" $prefix $dot }}*/}}  
{{ return $dot }}

layouts/partials/content-backlinks.gohtml

{{- $backlinks := partial "funcs/backlinks.gohtml" . }}  
{{ if $backlinks }}  
## Backlinks  
{{- end }}  
{{- range $backlinks }}  
{{- range $k,$v := . }}  
- [{{ $v }}]({{$k}})  
{{- end }}  
{{- end }}

layouts/partials/funcs/backlinks.gohtml

copied from https://github.com/milafrerichs/hugo-wikilinks/blob/main/partials/funcs/backlinks.html

<!-- Search for [[wikilink]] instead of "wikilink" when finding backlinks to prevent false positives: Otherwise, for a note whose filename/title is "now", every note containing the word "now" would be appended as a backlink)  
Regex not working for notes with colons on filename because hugo .File.BaseFileName returns a string with colons removed.  
-->  
  
{{ $firstBracket := `\[\[` }}  
{{ $optionalTitle := `(|.*)?` }}  
{{ $lastBracket := `\]\]` }}  
{{ $filename := .File.BaseFileName }}  
{{ $wikilink :=  printf "%s%s%s%s" $firstBracket $filename $optionalTitle $lastBracket }}  
  
{{- $.Scratch.Add "backlinks" slice -}}  
{{ $pages := .Site.RegularPages }}  
{{ $pages = where $pages "Draft" "==" false }}  
{{- range $pages -}}  
    {{ if (findRE $wikilink .Content) }}  
        {{ $.Scratch.Add "backlinks" (dict .Permalink .Title) }}  
    {{ end }}  
{{- end -}}  
  
{{- $backlinks := $.Scratch.Get "backlinks" -}}  
{{ return $backlinks }}