Homepage 404 or error

Suddenly, I start seeing this error in the console. I am not sure why.

I went to General -> Settings -> Reading -> Your homepage displays -> A static page (Set home as static page)

When I reload my frontity app this is what appears to be an error:

Do I need to create specific template and how for static pages? When I uncheck home page as being static, it works.

Hi @mh123

Have you set the homepage and postsPage properties for wp-source in frontity.settings.js?

See here for more info.

Yes, there is homepage set to point /. In my index page, in Switch statement I’ve added component to render when the page isHome. It works, it renders my template from Home component. But still I see this error. This is my config:

{
  name: "@frontity/wp-source",
  state: {
    source: {
      api: "http://dev.my-domain.test/wp-json",
      homepage: "/",
      postTypes: [
        {
          type: "services",
          endpoint: "services",
          archive: "/services",
        },
      ],
      taxonomies: [
        {
          taxonomy: "test", // taxonomy slug
          endpoint: "test", // REST API endpoint
          postTypeEndpoint: "services", // endpoint from which posts from this taxonomy are fetched
        },
      ],
    },
  },
},

When I print out in the console, this is what I see for source, the data/home/ returns an error. My app is calling the /home/ even when I remove home related stuff.

Maybe I don’t need to make homepage as static page in the wp settings at all? or should I? If I don’t have home as static page, how to set main route for home page?

Hi @mh123

Could you post all of your frontity.settings.js file please. Do you have /home/ in your menu configuration?

const settings = {
  name: "some name",
  state: {
    frontity: {
      url: "https://test.frontity.org",
      title: "Test Frontity Blog",
      description: "WordPress installation for Frontity development",
    },
  },
  packages: [
    {
      name: "@frontity/mars-theme",
      state: {
        theme: {
          menu: [
            // ["Privacy", "/privacy-policy/"],
            // ["Home", "/"],
            ["Services", "/services/"],
            // ["Nature", "/category/nature/"],
            // ["Travel", "/category/travel/"],
            // ["Japan", "/tag/japan/"],
            // ["About Us", "/about-us/"],
          ],
          featured: {
            showOnList: true,
            showOnPost: true,
          },
        },
      },
    },
    {
      name: "@frontity/wp-source",
      state: {
        source: {
          api: "http://dev.some-api.test/wp-json",
          homepage: "/",
          // postsPage: "services",
          postTypes: [
            {
              type: "services",
              endpoint: "services",
              archive: "/services",
            },
          ],
          taxonomies: [
            {
              taxonomy: "test", // taxonomy slug
              endpoint: "test", // REST API endpoint
              postTypeEndpoint: "services", // endpoint from which posts from this taxonomy are fetched
            },
          ],
        },
      },
    },

    "@frontity/tiny-router",
    "@frontity/html2react",
    "@frontity/head-tags",
  ],
};

export default settings;

Even if I put /home/ to menu or comment it out, it doesn’t metter. I get an error. I managed to get rid of an error by disabling home as static page. So, now when I access /home route it renders the page properly. Same with /about.

But now, when I access the base route / it renders the list of posts instead of my home page. How can I tell frontity which route to point to homepage?

For example: / route to get content from /home.

Maybe this is easier to achieve. And maybe I don’t even need static page? But then how can I differentiate home from the other pages?

Hi @mh123

Try creating a separate page for posts in the WP admin and setting it as the ‘Posts page’:

Then configure in frontity.settings.js:

postsPage: "news", // or whatever your page slug is

See if actually configuring a posts page (even if you don’t use it) makes that error go away. I think that as you’ve configured / as the homepage Frontity may now be looking for the posts at /home/, so explicitly configuring a posts page may sort it.

Thank you for replying. I did what you suggested. Now the posts are pointed to News page and it works fine. When I go to / it loads the home page. However, the error is still present.

UPDATE: I’ve found the problem, the cause was wp primary menu that I was fetching from my wp admin. Inside of this menu, there was link that pointed to /home route so I guess the server was trying to pre-load the page of /home which doesn’t exist. Few hours waisted.

1 Like