Is this by design: site.GetPage returns null if the URL has a fragment identifier appended

Hi

When I pass a URL with a fragment identifer to site.GetPage, it returns null. For example:

Case 1: {{- with site.GetPage "/doc/hello/#section1" }}
Case 2: {{- with site.GetPage "/doc/hello/" }}

Case 1 returns null, and Case 2 returns a correct URL.

Is this “by design”?

Using relURL function seems can solve the issue, but the URL cannot start with a ‘/’:

{{ relURL "doc/hello/#section1 }}

Any suggestion?

According to the docs for GetPage | Hugo

Returns a Page object from the given path.

I would treat Path as logical path not URL

An url incl an anchor never will be a logical path. Sounds logical :wink: to not find a page.

Mmh. It can see urls.RelURL | Hugo

Relurl does not do any page lookups. It just constructs an Url

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.