LinkResolver uses current path to build link

So, I just noticed this strange behavior, I must be missing something. I've created a local bike rental website. When I'm on the homepage the navigation works perfectly, but let's say I visit the services page and I would like to go to the bike repair page, the bike repair page is appended tot the services page.

Expected behavior: ""

Current behavior: ""

It looks like the LinkResolver somehow appends the current page to the url, this is unexpected. Does this look familiar to anyone?


const linkResolver = (doc) => {
    if (doc.type === 'page') {
        return `../${doc.uid}`
        return '/'

module.exports = linkResolver


const Services = () => {

  return (

      render={(data) => {

        const prismicContent = data.allPrismicNavigationServices.edges[0]
        if (!prismicContent) return null
        const doc = prismicContent.node 

            <ServicesList as="ul">
              {, index) => {
                  return (
                    <li className="nav-item" key={`link-${index}`}>
                      <NavLink to={}>

const servicesQuery = graphql`
  query servicesQuery {
    allPrismicNavigationServices {
      edges {
        node {
          data {
            services_navigation {
              link {
              link_label {

export default Services

With best regards,


Hey Kevin, what I imagine is that, the issue is not coming from the link resolver, but rather from the way you're generating your dynamic pages.

Which plugin are you using to do them? because, e.g., if you're using gatsby-node to generate them, this is where you create the URLs for each page using the data from the queries.

I'd like to know about this part of your project to better understand the use case

Dear Paulina,

Thank you for your response, I'm following the tutorial specified here;

The thing is, the tutorial still uses the gatsby-srouce-prismic-graphql but shows a notice above which states we should no longer use this plugin. From now on you should use the "gatsby-source-prismic" plugin.

Edit; I've included my gatsby-node.js down below;

const path = require('path')

exports.createPages = async ({ graphql, actions }) => {
  const { createPage } = actions

  // Query all Pages with their IDs and template data.
  const pages = await graphql(`
      allPrismicPage {
        nodes {

  const pageTemplates = {
    Page: path.resolve(__dirname, 'src/templates/page.js'),

  // Create pages for each Page in Prismic using the selected template. => {
      path: `/${node.uid}`,
      component: pageTemplates.Page,
      context: {
        // Data passed to context is available
        // in page queries as GraphQL variables.
        slug: node.uid,

As far as I can see the path generated for each page is correct.

When I have a look at the Link used in the navigation

<Link className="nav-link" to={}>

This appends the {} - " /bike-repair" to the current url, like it's a child page from the current page. Instead it should behave like regular page url.

This actually does the trick but it refers to the folder one level up even though that's not the case, it also returns "null" for the homepage.

<Link className="nav-link" to={`/${}`}>

I guess the Link component isn't properly using the linkResolver, it does not return "/{" it just returns the plain value for "{}" therefore appending the value to the url structure.

If the linkResolver points to the correct path with the slash, I should be alright...

1 Like

So indeed it was the linkResolver, I've updated the Nav component as follows;

  <ul class="nav-list">
    {, index) => {
      const linkTo = linkResolver(
      return (
        <li className="nav-item" key={`link-${index}`}>

I've imported the linkresolver directly

import linkResolver from '../utils/linkResolver'

Now when the document is of type page an url is build by the linkResolver instead of being used directly in the html document.

1 Like

Hey again, glad to see you managed to sort this out. i was going to tell you that you needed to pass the complete link to the. linkResolver to that it gets the full document metadata. But you figure it out yourself.

So is it working properly now?

And about the documentation for the gatsby-source-prismic-graphql plugin. We've talked about this a lot in the past, we have a dedicated article explaining why we're moving away from it and we can only apologise for all the complications that this causes to every user that has selected this framework to work with Prismic. We're currently working on changing the documentation to focus on the gatsby-source-prismic plugin alone. This plugin works differently, but we'll be able to have a little more control over the maintenance of it.

If you encounter any issues about this or anything else, be sure to contact us

This issue has been closed due to inactivity. Flag to reopen.