Jump to content

Code to remove "All" Category

Go to solution Solved by creedon,

Recommended Posts

Posted

I've created multiple product Categories and notice that when someone goes to the store page, the "All" (or whatever it's been renamed to) shows all products in all categories. I would like to hide/remove the All display and start by showing just the items in the top/first category. Is there a setting for that or some custom code to make that work?

Posted

This is just a test/demo page... I haven't populated it with multiple products in each category yet (as I want to see if I can get this to work), but by default when going to the page, all the products are shown. In this case, I'd want a user to go to this page and only see the top category items (March), then click on other months to see the items in those categories. 

Posted

I had renamed it to "Months" but then in the Store Settings - General under "TOP CATEGORY NAME" I had disabled the filter so that wasn't visible - I've turned that back on. With it on or off, when going to the page all products are shown....

Posted

That's only part of what's needed. " by default when going to the page, all the products are shown. In this case, I'd want a user to go to this page and only see the top category items (in this case, March), then click on other months to see the items in those categories. 

  • Solution
Posted (edited)

What you describe is not an unusual design pattern for the most part but Squarespace doesn't support what you describe natively.

A unique element of your request is to automatically have the first category become the "main" page for the store page. Although it is possible to determine the first category of the store page with JavaScript. The time it takes is too long in my testing to be practical.

So I think you are left with some JavaScript that would redirect to a category page you set manually.

The first trick is to never link directly to your /booking URL Slug.

Second you will want to redirect site visitors to another URL if they do make their way to your main (all category) store page.

Please see SPLACR Date Progression Redirect.

In my code you'd want to replace...

      '[ enter url here replacing square brackets ]' : '[ enter date here replacing square brackets ]',

...with something like the following...

      '/booking/march-2025' : '2025-03-01',
      
      '/booking/april-2025' : '2025-04-01',
      
      '/booking/may-2025' : '2025-05-01',
      
      '/booking/june-2025' : '2025-06-01',
      
      '/booking/july-2025' : '2025-07-01',
      
      '/booking/august-2025' : '2025-08-01',
      
      '/booking/september-2025' : '2025-09-01',
      
      '/booking/october-2025' : '2025-10-01',
      
      '/booking/november-2025' : '2025-11-01',
      

You would of course need to maintain the urlDateMap manually.

Let me know how it goes.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Posted

Thank you! It occurred to me that the simple solution is to just link to the first category. The suggestions regarding the redirects are very helpful.

Posted (edited)
On 6/16/2024 at 9:58 AM, GBC said:

the simple solution is to just link to the first category.

Some downsides to the link to category method and not using my redirect code is that it is possible for site visitors to get to the All category page. Search engines may index the All category page. To reduce the chance that it is, you'd need some JavaScript to add a robots noindex request to the All category page.

Also depending on the settings, a link to the All category page may be presented in the UI. You may need to use CSS or JavaScript to make those links go away.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.