Ref and relref do not work if it is in layout folder

if you use the following code:

{{ relref "content/post/" }}


{{ relref "post/" }}

hugo throws the following error

executing "partials/_left-menu.html" at <relref "content/post...>: error calling relref: invalid Page received in RelRef

I have the following folder structure:

- project
-- content
--- about
--- post
-- layouts
--- partials

Based on the error you probably missed out passing the context (the dot) to the partial.

You need to show the full code (the site git repo) to get more help.

@kaushalmodi thank you for the answer. I don’t know what the dot did mean, but if I remove rel/relref from html file then everything works well. The repo is here.

You need to add the page to the call to relref (i.e. the dot). I think it is the first argument:

{{ relref . “content/post/” }}

I meant a probable missing dot as the argument to the parent partial _left-menu.html.

Does relref function take two arguments? It’s documented to accept just one.

In single.html, try changing:

{{ partial "_left-menu.html" }}


{{ partial "_left-menu.html" . }}

That’s the dot I meant… search for “common mistakes” here :slight_smile:.

Hi there, I’m having the same issue, but the dot seems to not work.
According to the documentation ( I deduced that I had to use:

<a href="{{ ref "mypost.markdown" }}" target="_new">UK y Gales SPTA</a>


<a href="{{< ref "mypost.markdown" >}}" target="_new">UK y Gales SPTA</a>

None of then are working. Following this thread, I understood that I should use instead:

<a href="{{ ref "mypost.markdown" . }}" target="_new">UK y Gales SPTA</a>

but still not working.

Just in case it’s useful, here is my hugo version:
Hugo Static Site Generator v0.30.2 linux/amd64 BuildDate: 2017-10-19T13:34:27+02:00

It’s probably something silly, but I just don’t get it. Could you give any hint? Thanks for your time!

It’s difficult to give any hint without looking at the site source.

  1. You need to link your site repo
  2. Explain what one should do after cloning that repo to see the problem.

Hi! Thanks for your response:

  1. link to the repository:

  2. In the left sidebar there is a “CV viajero” section, inside you can see a map and a list. In this list, there are some links with “ref” (for instance “UK y Gales SPTA” at the top of the list). It should open the post with this name; instead, the “href” it’s badly rendered/processed with: “http://localhost:1313/cv-viajero {{”


Thank you for the answer. I get the same error.

Thank you guys, now it works. I had to apply @kaushalmodi solution with @bep solution. So:

// when calling partial template **the dot**
{{ partial "_left-menu.html" . }}


// then put the dot
{{ relref . "post/" }}

but it does not work with

{{ ref . "about/" }}

I guess it is documentation issue.

1 Like

Is there any way to bind to
I was expected:

{{ ref . "about/" }} // "/about"

get the following error:

ERROR 2017/11/17 16:26:33 Error while rendering "home": template: index.html:5:15: 
executing "index.html" at <partial "_left-menu....>: 
error calling partial: template: partials/_left-menu.html:35:7: executing "partials/_left-menu.html" at <ref . "about/_index....>: 
error calling ref: No page found with path or logical name "about/".

Same problem. Every ref or relref fails without any meaningful error. Tried everything above at random. The documentation is non-existant.