I’ve created a dynamic collection which lists future events, and have broken it down by state.
The collection has fields Title, State, Active
The URL is structured /events/{state}/{title}, and allows users to see all events in their state by going to /events/{state}.
The collection is filtered by Active == true, so that only future events are shown. This is manually maintained (for now).
The problem is that we don’t always future events for a given state, so the collection is filtered to zero items, and the page results in a 404. This is TERRIBLE for our SEO.
Example: we have a single event in Arizona today. /events/arizona works beautifully, and links to /events/arizona/{title}. But tomorrow, we’re going to filter out that event, and /events/arizona is given a 404. /events/arizona/{title} still works because want it for SEO purposes.
Is there any way to show that we want to keep /events/arizona? I don’t want to display dummy events because that is poor UX, and we would have repetitive text for a dummy event in each state, hurting our SEO.
Add code to link the button to a ‘No events found’ page if there’s no event planned.
I haven’t described what elements you were using, so I can’t add more specific details.
Thanks for your reply, here’s what I ended up doing:
I added dummy events to the collection
On the /events/{state}/ page, I moved querying from the connected dynamicDataset to javascript, using the wixData API to query for events that don’t match dummy == true. This makes the page valid (no 404) but doesn’t display the dummy events. I’m also able to display an empty state message if no events are found.
For each of the dummy events, I added their path to as disallow in robots.txt so Google doesn’t crawl them
Additionally, I used javascript to add metatags saying noindex, so they don’t appear in search results
I’m considering adding a 301 redirect from the dummy page (if a user navigates directly somehow) back to the /events/{state} page
This does what I need, though it puts more in code and makes the pages load a little ugly.
The first solution that come up to my mind is to split up your state field into its own collection and have a reference field pointing to state in your event collection. Then you’ll have /states/{name} pages, which will always return something.
You can then have a dataset that filter event based on the current state.
I haven’t played with creating dynamic pages with multiple collections, but this seems like it might work. Though I don’t know if it would allow me to have a single path structure /events/{state}/{event-name}.