Creating Streams template using data with no slug value

I currently have an account populated with only location entity data. I have over 1000 entities but none of them have a slug value. I also am not at liberty to edit them. I have a site that is connected to a starter repository that I have edited. I’m currently trying to make a location page using templates and streaming.

While following the guide to templates and streaming here, when I run “npm run dev”, I only get the stream from the same 10 entities, unsure if there is something in the empty starter repo defining this, but I poked around and didn’t see anything. In the local data, I can see the values from the entities in my account, but the console tells me they all do not have the document.slug value, so the pages are not being created. Error message:

No document.slug found for entityId "22", no link will be rendered in the index page.
No document.slug found for entityId "185", no link will be rendered in the index page.
No document.slug found for entityId "27", no link will be rendered in the index page.
No document.slug found for entityId "28", no link will be rendered in the index page.
No document.slug found for entityId "15", no link will be rendered in the index page.
No document.slug found for entityId "13", no link will be rendered in the index page.
No document.slug found for entityId "33", no link will be rendered in the index page.
No document.slug found for entityId "3", no link will be rendered in the index page.
No document.slug found for entityId "24", no link will be rendered in the index page.
No document.slug found for entityId "4", no link will be rendered in the index page.

I’ve tried not using the slug value at all, but this error persists. If I run “npm run serve” I run into a plug in error. I can’t find documentation about the json the error is referring to:

pluginFileMap.json not found, proceeding without plugins
WARN: Failed to parse plugins for repo: lstat /Users/belleroberts/Library/CloudStorage/OneDrive-Slalom/Documents/Yext/pfs-store-locator/.artifact-output/pluginFileMap.json: no such file or directory

Lastly, on the site itself, the build in the site page itself, the deploy has this error on page generation:

Path conflict detected at /. between entity ID: 49005786, locale: en, template: location and entity ID: 49005822, locale: en, template: location. This error is likely caused by one or more entities having the same value for the slug field. Ensure the above entities have unique slug fields so that each generated URL is unique.

I’m assuming because the entities don’t have a slug value, they are considered to be all the same.

Is there a work around to use a field other than the slug value so that I do not have to edit my entities?

Hi Belle,

Regarding you first question, the system only generates 10 JSON documents per entity template in local development so this is expected behavior.

We recommend using the slug field for your URLs as we outline here. That being said you can do a few things to mitigate the issues you are seeing (also outlined in the linked doc):

  1. Instead of running npm run dev, try running npm run dev -- --no-prod-url. This command will serve your local URLs in the following format, which will only be used locally and will not match what is served in production: localhost:5173/[template-name]/[entity-id]
  2. To avoid path collisions, make sure your getPath function returns something unique. The following code sample is derived from the Pages locations starter:
export const getPath: GetPath<TemplateProps> = ({ document }) => {
  return `${document.locale}/${document.address.region}/${document.address.city}/${
        document.address.line1
      }-${document.id.toString()}`;
};

Let us know if you are still having issues.

Aaron

Thanks Aaron, this did solve my issues in dev, but I wanted to follow up. Does that mean prod requires the use of slugs even if we return a completely different string for GetPath? What is the behavior of prod if the entities don’t have slugs?

The pages will be served at whatever is returned by the getPath function so you shouldn’t see any issues. However, we do not recommend using non-slug fields for your production urls as the slug field contains special logic to ensure that your urls will be valid strings. Note that the slug field does not protect against collisions so you would still need to make sure each slug is unique.