Follow this guide to make your NodeJS translated website SEO-friendly, and work with optimal performance. 

  • This guide is aimed for Express.js servers. If you are using a different framework in NodeJS, contact [email protected]

1. Install the Bablic npm package

npm install --save bablic

2. Add Bablic middleware to your app.js file: (If you are not using ES6 code, use var instead of const).

const bablic = require('bablic');
const options = {
  site_id: '[your site id]',
  root_url: 'http://[root url of your site]',
  //subdir: true, // <- if you want to use sub dir for languages like /es /fr
  seo: {
//    default_cache: [] // list of URLs you want to force preloading cache for.

// use Bablic middleware (must be before the routes handlers)

// example of a standard web page handler
app.get('/',function(req,res) {
   console.log('the current language for the user is',req.bablic.locale);

3. Add the snippet to your layout html template to make sure your snippet is always updated and performs optimally: (This example uses EJS templates, but the bablic local can be used in any rendering language)

      <%- bablic.snippetTop %>
      <%- body %>
      <%- bablic.snippetBottom %>


To enable sub-directories simply use set "subdir" as true, to the Bablic middle-ware.

That's it. You can go on and click "Verify" on your Bablic SEO Configuration Wizard and complete the integration.

Did this answer your question?