How to use Link Resolver

Hi Friends, I am new to prismic at the moment I am struggling to understand how to configure this linkResolver. There is lot doc out there but it is random at each phase. All I need to do is simple one.
I have this plugin 'gatsby-source-prismic', and this is my linkresolver function under gatsbyconfig.js
I am trying to understand when this configuration will get called. console log does not even get called.
And i am not abble to call different index.jsx based on the doc type

linkResolver: ({ node, key, value }) => (doc) => {
// Pretty URLs for known types
if (doc.type === 'blog') return "/post/" + doc.uid;
if (doc.type === 'page') return "/" + doc.uid;
// Fallback for other types, in case new custom types get created
return "/doc/" +;


Welcome to the Prismic Forum, and thanks for reaching out to us.

Link Resolver function is used for internal routing for your project and create URLs accordingly.

Your linkResolver code in gatsbyconfig.js looks fine, and it will get called when you build the project, and console logs for this will be printed at the server console/terminal. Thus, for checking console logs, you need to stop and start the server again.

If that does not resolve the issue, I would love to dig your code. For this, I will need your source code and repo. (you can send a private message to me)

Thank you,

HI @Priyanka thanks for the reply, I am kind of blocked on this. All I want to render the pages dynamically based on the uid of the document. I have multiple documents on prismic with different uid.
All these documents have different images but the design is same like uid's of the components.
So, I have a react component which literally renders the page as longs those uid's matches.
How can I use this component to render the two documents on separate urls.
at the moment it is always renders at root ('/') url but I want access new url like 'localhost:8000/brochure/A' and render the same component which rendered at root url ('/').
can you able to help me with this .

            // (optional, builds pages dynamically)
            type: "homepage", // TypeName from prismic
            match: "/brochure/:uid", // Pages will be generated under this pattern
            path: "/brochure", // Placeholder page for unpublished documents
            component: require.resolve("./src/pages/index.jsx"),
            // component: require.resolve("./src/04.templates/brochure.js"),

I see the below error on the screen


In order to solve this, I will need

  1. Your Github repo or zip file (you can send me a private message)
  2. The URL of your repository.


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