Category pages not working / 404

Hi,

Iā€™ve just migrated my regular WP site to an AWS+Vercel hosted Frontity site and it was mostly a smooth process (great Tutorial by the way, Frontity team!).

However, I canā€™t seem to navigate to my category pages. They return a 404.

I canā€™t share my code as itā€™s not in a repository yet, but Iā€™m just using the twenty-twenty theme provided by Frontity. No modifications made.

Site is here: https://www.robcallaghan.co.uk/

WP source/ API is here: https://wp.robcallaghan.co.uk/

I see an error in the console regarding a string being ā€˜splitā€™ but Iā€™m not sure if this is related.

Any ideas?

Thanks in advance.

Hi @rob_cal_uk

Welcome to the Frontity community.

Did this work for you in your dev environment? Iā€™ve set up an unmodified twentytwenty-theme locally and I canā€™t access any categories from your endpoint. I also get the ā€˜splitā€™ error in the console.

What permalink settings are you using in WordPress? What happens if you try changing them?

Hi @mburridge - thanks for replying.

It didnā€™t / doesnā€™t work in my dev environment (which still pulls from the live WP site) and even with a different theme.

See permalink settings below:

Iā€™ve just changed the category base from empty to ā€œblogā€ and then to ā€œtopicsā€ and neither worked.

Hi @rob_cal_uk

What happens if you use a setting other than Custom Structure, e.g. Post name?

@mburridge I changed it to just the post name and it works. Great! But sadly not ideal.

To confirm, I changed it back to the Custom version (posts prepended with /blog) and the category archive pages stopped working again.

Any ideas whatā€™s going on?

hi @rob_cal_uk

Have you changed the category base setting in Settingsā†’Permalinks?

Hi @mburridge

Changing the category base to blog results in a 404 too.

Iā€™ve always been able to see the categories in the state (perhaps you have also) - screenshot below - so I donā€™t understand why the app cannot display them.

image

Shall I report this as a bug somewhere - or is there more exploration to do?

Hi @rob_cal_uk

Try using the ā€œPost nameā€ permalink setting, but with ā€˜blogā€™ in the ā€œCategory baseā€. What happens then?

It looks like that for categories isFetching remains true, and isReady remains false implying that nothing is coming back from the endpoint for that route.

@mburridge No luck, Iā€™m afraid! Still returning 404sā€¦

Hi @rob_cal_uk

Hmm :thinking:. Can you create a repository and post a link here. Iā€™ll clone it locally and try to see whatā€™s going on.

@mburridge here you go: GitHub - robdcal/robcallaghan-co-uk-frontity

Thanks for looking into this.

Hi @rob_cal_uk

Iā€™ve cloned your repo and managed to get it working.

Try adding a categoryBase property to the wp-source settings in frontity.settings.js.

{
      "name": "@frontity/wp-source",
      "state": {
        "source": {
          "url": "https://wp.robcallaghan.co.uk",
          "categoryBase": "/blog/category"
        }
      }
    }

The value here will be what you define in Settings ā†’ Permalinks ā†’ Category base in the WordPress admin.

Let me know how you get on. For more info see here.

Thank you @mburridge - works perfectly.

Do you know if the issue was that the base URL for category pages wasnā€™t defined at all, or that thereā€™s a default set for the categoryBase value which didnā€™t match my specific setup?

Hi @rob_cal_uk

There isnā€™t a default for categoryBase. If you leave it out of your configuration in frontity.settings.js and look at the state youā€™ll see that itā€™s just an empty string. I think the problem was that you had the Category base set in the WP admin, so you also needed it in your Frontity configuration.

Iā€™m glad you managed to get it working. :raised_hands: