skip to Main Content

I have created my blog as a single page application using mithril framework on the front end. To make queries I’ve used a rest API and Django at the backend. Since everything is rendered using javascript code and when the crawlers hit my blog all they see is an empty page. And to add to that whenever I share a post on social media for instance all Facebook sees is just an empty page and not the post content and title.
I was thinking of looking at the user agents and whenever the USER-AGENT is from a crawler I would feed it the rendered version of the pages but I’m having problems implementing the above method described.

What is the best practice to create a single page app that uses rest API and Django in the backend SEO friendly for web crawlers?

3

Answers


  1. You might want to look into a server-side rendering of the page that crawlers visit.

    Here is a good article on Client Side vs Server Side

    I haven’t heard of Mithril before, but you might find some plugins that does this for you.

    https://github.com/MithrilJS/mithril-node-render

    Login or Signup to reply.
  2. I’m doing this on a project right now, and I would really recommend doing it with Node instead of Python, like this:

    https://isomorphic-mithril.mvlabs.it/en/

    Login or Signup to reply.
  3. This might help you : https://github.com/sharjeel619/SPA-SEO

    The above example is made with Node/Express but you can use the same logic with your Django server.

    Logic

    • A browser requests your single page application from the server,
      which is going to be loaded from a single index.html file.
    • You program some intermediary server code which intercepts the client
      request and differentiates whether the request came from a browser or
      some social crawler bot.
    • If the request came from some crawler bot, make an API call to
      your back-end server, gather the data you need, fill in that data to
      html meta tags and return those tags in string format back to the
      client.
    • If the request didn’t come from some crawler bot, then simply
      return the index.html file from the build or dist folder of your single page
      application.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search