Ishai Jaffe avatar
Written by Ishai Jaffe
Updated over a week ago

Follow this guide to make your PHP translated website SEO-friendly.

How To Use:

  1. Download "bablic.php" from the Github repository into your php index folder.

  2. Place this snippet at the top of your index.php file, if your website has header.php or head.php that is used in all pages, it might be the right place to put the code in.

// init the Bablic SDK with your site ID (required)
require 'bablic.php';
$site_id = 'your site id';
$bablic = new BablicSDK(
        'site_id'=> $site_id

// run the SEO middlware
        'debug' => false, //optional
        'nocache' => false, //optional
        'url' => '' //optional

# Example: how to paste the snippet in your HTML for optimal performance
       <title>A most unique website</title>
       <?php echo $bablic->bablic_top() ?>
       A most unique content

And that's it, you can continue and click "Verify" in the Bablic SEO Configuration Wizard to validate the installation.


site_id - required string, your Bablic site id.

nocache - optional boolean, when true does not use cache. Defaults to false

url - optional string, if you ever need to query Bablic for a different domain (testing, staging, etc)


handle_request() - request middleware, renders html optimized for crawling engines, only to crawling engines

bablic_top() - generates the snippet code to put in the page head tags. This method must be run anywhere inside the page <head> tag.


For SEO reasons, it is sometimes recommended to use sub-directory for each translated language (for example:,
To have your translated website work with language sub-directories you'll need to complete 2 steps:

Handle rewrite in your Apache/NginX configuration


Add this code to your Apache configuration file or .htaccess file, and replace the language codes (de/es/it) with your own website language codes:

RewriteEngine on  	
RewriteRule ^(de|es|it)\b(.*)$ $2 [PT,QSA]

Add this location section above other your other location definitions, and replace the language codes (es/de) with your own website language codes:

location ~ ^/(es|de)/ {
      rewrite ^/(?:es|de)/(.*)$ /$1;

Reload the Apache/NginX process to force the server to run the new settings.

You can click the "Verify" button in your Bablic SEO Configuration Wizard to validate the sub-directory installation.

Did this answer your question?