After spending 5 years developing compliance software I recently started freelancing again so I could “Modernise” my skillset.
This involved a bit of an industry trend assessment.
I found myself veering towards React. Then after looking at Gatsby and Next (as replacements for the traditional understrap based sites) I discovered the shiney new Frontity framework.
Which seemed perfect.
So, I’ve spent the past couple of weeks playing with Frontity to build my new website,
you can check it out here: https://primitivedigital.co.uk/
I must admit I’m impressed with Frontity, I’ve hit hardly any errors, which for a brand new framework is quite an achievement.
This is my own website so I can be a little experimental. As such I’ve included quite a bit of animation and image loading to measure performance impact.
Hi @shaun. As I told you last week, I wanted to give you some comments about the code
Build folder
First, you should be able to remove the /build folder from your git repository and add it to your .gitignore file because the new Now builder (@frontity/now) runs the build step in the cloud.
If it doesn’t work let me know and we’ll try to figure out why.
Routing with custom React elements
If you want to use a custom React element for the homepage, it’s better if you switch to “or” syntax. Instead of this:
That means that if <Home /> loads, <Post > won’t. Even if the homepage is a "page".
We want to release a <Switch> component to make this easier in the future.
Package name
You don’t have to start your package with "@frontity" (like "@frontity/primitiveone").
Actually, as that name is the npm package name, you can name it only "primitiveone" or use your own npm organization scope.
Apart from that I see some 404’s right now because your WP site is down. Let me know when it’s up again and I’ll take another look at the code to see if I can help you more!
It was only one file, build/server.js, that seemed to be getting commited.
I have manually removed it and added an exclude rule for the file.
Routing with custom React elements
The previous 404 issues seemed to be caching.
The <Switch> sounds good.
Changing this syntax breaks my current setup.
Reading your comment has made me realise I am just loading and consecutively here…
Hi !
Can you please tell me that how you ran YoastSEO sitemap.xml on your site ?
I am also doing it in a same way but always getting error of 404. So please help me.
Thanks
Yoast SEO will automatically create a 301 for /sitemap > /sitemap_index on your WP install so just point your redirect at that.
To get the client side URL displayed in the sitemaps I had to hack the core files in Yoast SEO to replace the root URL and disable auto-updates (there’s a few issues open re: headless support in the yoast repo, I think the official line is it’s not supported yet).
I updated this code in the plugins/wordpress-seo/inc/sitemaps/class-sitemaps-renderer.php
/**
* Build the `<sitemap>` tag for a given URL.
*
* @param array $url Array of parts that make up this entry.
*
* @return string
*/
protected function sitemap_index_url( $url ) {
$date = null;
if ( ! empty( $url['lastmod'] ) ) {
$date = $this->date->format( $url['lastmod'] );
}
// sk-dev-Hack
$frontend = "primitivedigital.uk";
$backend = "api.primitivedigital.uk";
$url['loc'] = str_replace($backend, $frontend, $url['loc']);
$url['loc'] = htmlspecialchars( $url['loc'], ENT_COMPAT, $this->output_charset, false );
$output = "\t<sitemap>\n";
$output .= "\t\t<loc>" . $url['loc'] . "</loc>\n";
$output .= empty( $date ) ? '' : "\t\t<lastmod>" . htmlspecialchars( $date, ENT_COMPAT, $this->output_charset, false ) . "</lastmod>\n";
$output .= "\t</sitemap>\n";
return $output;
}
I wouldn’t really say this is a recommend way of doing this, @koli14 was also looking into similar issues at the time, not sure if he’s got a better solution…
Thanks sir for explaining in a very good way. But i think it won’t be helpful for me because i have deployed my site through dockers and also i don’t want to open Yoast SEO sitemap file. I want to open my own generated sitemap.xml on my frontity web (I generated that file through react-router-sitemap) which contains only front-end routes.
OK sir sure. I am opening a new ticket. Yes you are right i want to open a root/public file named as sitemap.xml generated from react-router-sitemap same like robots.txt