What Wordpress Theme to activate?

Hi,

Maybe a dumb question but could not find any info on this, what theme should I activate on the WP dashboard (even though it doesn’t render this) and how to hide it from the public?

You can use something like Nude:

We haven’t released it yet, but our PHP plugin will be capable of overwriting your theme and you will have some options, like:

1 Like

Perfect thanks for the info.

I was thinking of doing something like this

<script type="text/javascript">
  window.location = 'https://my-site.com';
</script>

but I was wondering what best practice stipulates when using WP headless.
Security and SEO wise what would be the best option if a user hits your API homepage?

PS looking to contribute to this project in the new year.

I think the safer option is probably a 301 redirection. I’m going to ask our SEO expert and I’ll get back to you.

Awesome! Let us know and we’ll help you get onboard :smile:

Hi @b-b0t ! The best approach SEO-wise is indeed what @luisherranz commented: doing a 301 redirect from any URL from the API site to the public site where Frontity is installed, except any URL that starts with “/wp-json” (as that’s what Frontity needs in order to get the content of your site).

You should redirect each URL to the corresponding URL on the Frontity site (so, homepage to homepage, post to post, category to category, etc.)

Ideally you should do this creating a rule on the .htaccess file on the API server so Googlebot won’t depend on rendering the page and executing JS to see the redirect.

Hope that helps!

Hmm… maybe we can provide:

  • The .htaccess rule.
  • The Nginx rule.
  • A regexp string people can add to a WP redirection plugin (like this one, this one or this one).

@christianoliveira do you know how to do this with .htaccess? I can look for Nginx and WP plugins.

Sure!

The following lines would do the trick included on the .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule !^(wp-json|wp-admin|wp-login\.php|wp-includes|wp-content|wp-comments-post\.php|wp-cron\.php|wp-trackback\.php|wp-signup\.php|xmlrpc\.php)(\/|$) http://domain.com%{REQUEST_URI} [L,R=301]
</IfModule>

A similar thing can be achieved with this plugin: https://wordpress.org/plugins/simple-website-redirect/ , configuring it like this:

Exclude Paths:

/wp-json,/wp-includes,/wp-content,/wp-comments-post.php,/wp-cron.php,/wp-trackback.php,/wp-signup.php,/xmlrpc.php,index.php

Note that this plugin adds exceptions by default to some of Wordpress’ URLs like /wp-admin or /wp-login.php

Depending on the specific setup, there may be some variations. For example, if your API site is configured in wp.domain.com/blog/ you may need to specify /blog/wp-json on the “Exclude Paths” section.

1 Like

Hey, I didn’t know Micah Wood had a redirection plugin. It looks really neat, thanks Chris :slight_smile:

@christianoliveira thank you for the detailed explanation, I usually want to know why something is better than an alternative and you nailed it :smiley: The plugin may indeed be better if it’s a PHP based redirect because .htaccess propagation can be time-intensive.

I am trying out something a little more complex though, I have Frontity on a subdomain (blog) and the WP installation on another (cms) with a Next.js project running on the primary - How would I go about having a route /blog point to frontity across two installations? And how does that affect the redirects?

PS Node stuff is on Now and WP is on AWS Lightsail.

@luisherranz I will be using the above project as a testbed for various plugin ideas I have for Frontity. Just want to get this setup and I can start contributing. :man_technologist:t3:

Already saved this forum as a Chrome App :stuck_out_tongue:

@b-b0t no worries, that’s why I am here!

Could you be more specific about your setup? If I’m understanding correctly, you have:

And you want the blog to be accesible by end users at domain.com/blog/, is that correct?

It will work as long as you put the Frontity project inside the /blog folder and add this now.json file to the root:

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@now/next"
    },
    {
      "src": "blog/package.json",
      "use": "@frontity/now"
    }
  ]
}

I’ve created a the repo example: https://next-and-frontity.luisherranz.now.sh/
And this is the deploy: https://next-and-frontity.luisherranz.now.sh/

@christianoliveira This is correct, I don’t think the blog on the subdomain is necessary anymore because @luisherranz solution worked perfectly. I actually didn’t know Next would create a route when adding a folder to root and not in the pages directory.

So then I suppose my final question would be what to do with SEO and configuration in this particular setup?

@b-b0t You would have, then:

The redirects that you need to setup are exactly the same as described above, but using domain.com/blog/ as the destination instead of domain.com (if you use the plugin, you have to define http://domain.com/blog/ as the “Redirect URL”). Let us know if it works!