Preview Links append "index" to URL

Hello all,

I have the Show_preview_links option enabled for my collection. The “view preview” or “view live” links add “index” to the end of the url. For instance:

The link should be - www.myblog.com/blog/post

but it renders as - www.myblog.com/blog/post-index

Is there a way to change this? It also affects unpublished posts in the editorial workflow.

It seems like another user has the same issue:

Incorrect preview link for nested structure back in February of '21.

We’re both using a nested structure, (blog/post-title/index.md)

I suspect this may be causing the issue?

How does Netlify-CMS handle preview links when the collection is nested?

I found the solution:

preview_path: '{{dirname}}'

Was the correct line, which I found via this thread.

Hope it helps other HUGO users in the future!

EDIT: I also had to add the specific directory manually, so in my case:

preview_path: 'blog/{{dirname}}'

I suppose the work-around here is to change each instance per collection to reflect which directory to correctly point to.

1 Like

Thanks for reporting back. It’ll definitely be of use to other users!