Static generation does not render some breadcrumb segments
We're using SSG for the production deployment of our site, and working locally in the standard, non-static mode.
I've noticed there are sections of our site in which the last part of breadcrumb doesn't render. Example here. Production builds run on Vercel, following the instructions in your docs.
The same page running locally displays the breadcrumb as expected.
Environment
Application Name: Amplitude Documentation
Laravel Version: 10.40.0
PHP Version: 8.2.16
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: amplitude-docs.test/docs
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: null
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file
Statamic
Addons: 2
Sites: 2 (Amplitude Documentation, Amplitude Documentation - Japanese)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.3.0 PRO
Statamic Addons
pecotamic/sitemap: 1.4.7
statamic/ssg: 3.0.0
This is still an issue for us. This issue seems to happen on some collections, but not others, and is happening more often.
We don't see any errors in the SSG output, and have updated Statamic to 5.31.0 and SSG to 3.0.2.
Additionally, running ssg locally on my machine produces no breadcrumbs at all.
Additionally, running ssg locally on my machine produces no breadcrumbs at all.
Hmm, I pulled down your repo and was able to generate breadcrumbs locally on your site fine 🤔
That said, I'm on PHP 8.3. I suspect it may have more to do with how you're configuring your .env and deploying your /docs.
For example, I was getting 404s on nested pages until I tweaked APP_URL in my .env, from what you had in your .env.example:
APP_URL=http://amplitude-docs.test/docs
Which I had to change to:
APP_URL=http://amplitude-docs.test/
I'm curious to know more about what you have set for that in your .env locally, versus where you're running ssg:generate for production?
This issue seems to happen on some collections, but not others, and is happening more often.
If you take a collection or page that doesn't render properly, does it consistently not work across multiple generations? Or is there a randomness to when it does or doesn't work, on a specific page?
Thanks for the response @jesseleite!
I was able to reproduce your results locally, which is awesome. I think I had included /docs in the APP_URL when using Vite, but obviously don't need that anymore.
I tried to replicate this setting in Vercel for our production build, APP_URL=https://amplitude.com, but it didn't seem to help. For example, here's the page from the screenshot.
@markzegarelli Hmm, assuming everything is working as expected locally, I'd need to know more details on your vercel env/config.
I can try playing with a vercel deployment next week as well.
Hi @jesseleite, I hope you had a nice holiday period.
I was poking around with this a bit more today, and noticed that on Vercel, their system environment variables don't include the protocol.
However, when I set my APP_URL to match, SSG errors out here, because it expects the scheme to be present.
I don't know if this could actually cause the issue, but it's a difference I noticed between my dev environment and prod.
Edit: I tried using the Vercel provided URL, but that didn't help.
As for the collection variability, it's consistent across generations.
For example, this page has complete breadcrumbs (collection), whereas this page at the same level, but in a different collection, doesn't.
Hey @markzegarelli, I apologize for the delay here...
I don't know if this could actually cause the issue, but it's a difference I noticed between my dev environment and prod.
Good to know!
Also, how are you managing to even get a successful build/deployment in the first place? I'm realizing that our suggested build script is obviously out of date, can't get Vercel to build at all here...
@jesseleite I'm using Node 18 for this project, which Vercel says uses the legacy build image. My guess is that was the default when the instructions were written.
The build image for Node 20 or 22 uses the Amazon Linux 2023 repository, which doesn't include amazon-linux-extras.
@markzegarelli Oh wow, okay I'm able to reproduce the issue locally now. It all depends on cache/stache state when running ssg:generate.
We're not sure this is a problem with the ssg, but possibly a bug in core. Will leave this open for now, but in the meantime you should be able to workaround this by adding php please stache:warm right before ssg:generate in your build.sh script...
I'm using Node 18 for this project, which Vercel says uses the legacy build image. My guess is that was the default when the instructions were written.
Also that clears things up regarding that error, thank you. We'll look into updating our instructions for the newer vercel build image!
Amazing! Thanks @jesseleite!
Fwiw, I did get an error in the build related to the spinner that displays in the terminal while the stache is warming, but it did not impact the output.
Cheers!
Oh interesting. Does running with -n -q flags suppress that spinner error?
👍 Yup! That cleaned everything up. Thanks again!