Assume relative url = /post/2017/
This line but with the variable as $regex, $stringify, $ trim etc they all fail
{{ $home := $.Site.GetPage “section” $regex }}
- regex (fails)
{{$link := .RelPermalink }}
{{ $regex := replaceRE “^/|/$” “$1” $link }}
- Try the string function (fails)
{{ $stringify := string $regex }}
- Try avoiding regex and using trim function (fails)
{{ $tri := strings.TrimRight “/” $link }}
{{ $trim strings.TrimLeft “/” $tri }}
- If you use a string which is exactly the same it works
{{ $string = “/post/2017/” }}
This is the problem, I can’t put a variable in the site.getpage thing it says:
runtime error: invalid memory address or nil pointer dereference
But I don’t know why. All the output above from RelPermalink looks like /post/2017/, the same as just string $var := “/post/2017/”. But it doesnt work
EDIT
So I just found this post String literal works, but (seemingly) equivalent argument doesn't?
And used this:
I’m still pretty shaky on Hugo, but Ill learn I guess.