Skip to main content

Posts

Showing posts with the label #sitecorejss

Sitecore XM/XM Cloud - Exclude specific Sitecore items from prerendering Sitecore JSS

Hi Team, Today's post will interest most of the coder and Sitecore technologist who are working in Sitecore JSS apps and want to ignore some paths from prerendering and also want to it to content manage them, so those items which you want to ignore can be in sitecore and everything will work dynamically. I am going to talk about how to exclude specific pages from being prerendered  Till now, I believe most of you know how to prerender pages in Sitecore JSS apps using NextJS, Using getStaticProps function, Basically it generates static version of your Sitecore page and prerender it and save it on the server disk, so the loading of the page becomes faster and site performance is improved so i will not cover that and there is a great documentation out there on Sitecore jss site  https://doc.sitecore.com/xp/en/developers/hd/19/sitecore-headless-development/prerendering-methods-and-data-fetching-strategies-in-jss-next-js-apps.html  I will cover the scenarios on "How can you ex...

Sitecore XM/XM Cloud - DefaultSitemapQuery errors out if excludepaths has space in item name

Hi Team, Recently, we had a requirement we needed to prerender pages in NextJS using GetStaticProps but excluding some pages, but it was failing due couple of reasons, I created two blog post around it  1)  Sitecore JSS - Error: `redirect` can not be returned from getStaticProps during prerendering (daivagnananavati.blogspot.com) 2)  Sitecore XM/XM Cloud - Exclude specific Sitecore items from prerendering Sitecore JSS (daivagnananavati.blogspot.com) First blogs explains, what issues we run into while prerendering pages and what is not supported at build time, it is good to understand the concept of prerendering and why redirects does not work while prerendering and second blog explains once we knew redirect items in GetStaticProps does not work at build time, what are the possibilities and what is that we did to exclude those items from being given to GetStaticProps, so that it ignores those items and does not prerender them and build gets successfully built. Today, in th...

Sitecore JSS - Error: `redirect` can not be returned from getStaticProps during prerendering

Hi Team, Recently in one of my project, I faced situation where we had getStaticProps complaining that it is not able to prerender some items and those paths were failing to build the app. so scenario was everything was working fine and build was working, but then there were redirect items added to sitecore content tree and form that day onwards "npm run build" started failing out of the blue with following errors First it was hard for me to wrap my head around it because, our Sitecore tree had different redirect items created from standard JSS redirect templates, so those redirect item were old URLs and in the field "redirectURL" we had the new page's path selected, because they are items just like any other items, I was expecting GetStaticProps to work, but build time only it was failing our NextJS getStaticProps looked like below  Basically, NextJS code in GetStaticProps meant following  1) GetStaticProps should prerender all the pages at build time 2) If it...