Shouldn't `.PageRef` links have a trailing slash?

I found a lot of posts by people trying to get rid of trailing slashes, but I seem to have the opposite problem. The docs write the pageRef property without trailing slash, as below:

menus.toml

[[nav]]
  name = "Home"
  pageRef = "/"
  weight = 1
[[nav]]
  name = "Press"
  pageRef = "/press"
  weight = 2

Template:

<li><a href="{{ .PageRef }}">{{ safe.HTML .Name }}</a></li>

Produces:

<li><a href="/press">Press</a></li>

I would have expected a trailing slash there, as with other links produced e.g. via .RelPermalink. Am I mistaken in desiring that behavior? What do you recommend?

That is incorrect. Do this instead:

href="{{ .URL }}"

The PageRef method isn’t documented, and there’s a reason for that.

1 Like

Thank you Joe, using .URL does it! I don’t know how I ended up with the other method.

1 Like

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