0

I'm trying to create a page per item of data from my CMS in 11ty. The data has pulled through nicely, and each page outputs nicely. However, when created a permalink I'm getting:

public/page-title/1/index.html

Where /1/ is the iteration of the creation of the page. I've never come across this with 11ty before - does anyone know why this happens and how I can prevent it? The docs weren't particularly helpful - saying it would happen but not why or any work arounds.

Thanks!

Rohan Thacker
  • 5,377
  • 3
  • 21
  • 34

2 Answers2

2

If you want to remap the permalinks for pagination, you can set the permalink front matter variable, which supports template strings (11ty docs).

You can change the permalink to be whatever you want, as well as access the paginated object (made simple with an alias). For example, if you have a slug property on your aliased object, you might want something like this:

---
pagination:
  data: cmsdata
  size: 1
  alias: item 
permalink: "public/page-title/{{ item.slug }}/index.html"
---
person_v1.32
  • 2,641
  • 1
  • 14
  • 27
  • Thanks. This is what I'm doing - but I am getting back public/page-title/8/index.html where 8 is the iteration of the data - for example I have a page for each item with number 1-8, and for the first iteration, no extra folder at all. – Steven Marks Nov 08 '21 at 12:48
  • Having worked on this today, it seems the problem is coming from using EleventyComputed. – Steven Marks Nov 08 '21 at 13:56
1

Through further research it turned out the problem was through using permalinks in eleventyComputed - there is a workaround as detailed in this thread:

https://github.com/11ty/eleventy/issues/1555

TL;DR: set permalink to : "/" before setting your permalink to the path you want in eleventyComputed