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 SettingsPermalinks?

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 SettingsPermalinksCategory 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: