AngularJS and SEO Errors - 404 in One Page Application

I am building a website using Express and AngularJS, but I'm pretty new to this technology, and I'm starting from the old plain PHP / HTML / JS. I understand the basics of this new approach, but I'm interested in learning about the best methods for SEO.

Let's say I have a website built as follows:

  • The RESTish API for interacting with it takes care of authentication, sessions, and providing the correct data.
  • A one-page application that first loads and is provided statically, which takes care of loading content using the AngularJS function

Here's a draft:

- /api (dynamic content returns JSON) | + /login + /logout + /register + /music/:title + /music/:title/upvote + /user/:name + /user/:name/subscribe + /tag/:name + /search/:query + ... - / (everything is static here) | + index.html + /templates | + music.html + user.html + search.html + ... 

Now whenever a user accesses a page, index.html returned, which then proceeds to โ€œlayoutโ€ using Angular.

Therefore, if the resource is not found, then a 404 NOT FOUND API (which uses JSON) or AngularJS .otherwise will be sent, but how the scanner can understand it as 404 (dead link) and remove the link if the first page returned when the URL was opened, is an index and the status code is 200?

A manual solution may be to parse the URL when the index is first required, call the API to check if the resource is valid, and if necessary, throw an error, but in this case, if the requested resource is valid, then there will be a double API call and itโ€™s not good.

What are the best management practices to solve this problem and other similar SEO related issues?

I already read a lot of articles about this, but they are either either outdated or based on preliminary rendering (which I would like to avoid).

Thanks so much for any help and advice you can give me.

+5
source share

Source: https://habr.com/ru/post/1247539/


All Articles