SEO-Friendly URL (Slug) Setup

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Setting up SEO-friendly URLs for your site

SEO-friendly URL — readable, understandable page addresses without technical parameters. They affect CTR in search results (users see URL in snippet), link perception, and indirectly affect ranking.

Principles of good URLs

Bad Good
/product.php?id=4521 /products/iphone-15-pro-256gb
/cat/12/sub/45 /catalog/smartphones/apple
/articles/2024/03/15/post-1 /blog/how-to-choose-laptop
/page?lang=ru&id=about /about-company
/Products/Laptops/Dell /products/laptops/dell (lowercase)

Rules:

  • Only lowercase letters
  • Separator — hyphen, not underscore
  • Without technical IDs (if possible)
  • Transliteration or semantic English translation
  • Logical hierarchy reflecting site structure
  • Without unnecessary stop words: the, and, or, for

Slug transliteration in Laravel

use Illuminate\Support\Str;

// Simple transliteration via iconv
function translit(string $text): string
{
    $text = mb_strtolower($text);
    $cyrToLat = [
        'а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'yo',
        'ж'=>'zh','з'=>'z','и'=>'i','й'=>'y','к'=>'k','л'=>'l','м'=>'m',
        'н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u',
        'ф'=>'f','х'=>'kh','ц'=>'ts','ч'=>'ch','ш'=>'sh','щ'=>'shch',
        'ъ'=>'','ы'=>'y','ь'=>'','э'=>'e','ю'=>'yu','я'=>'ya',
        ' '=>'-','_'=>'-',
    ];
    $text = strtr($text, $cyrToLat);
    return preg_replace('/[^a-z0-9\-]/', '', $text);
}

// In model
protected static function boot(): void
{
    parent::boot();
    static::creating(function (self $model) {
        if (empty($model->slug)) {
            $model->slug = static::generateUniqueSlug($model->title);
        }
    });
}

protected static function generateUniqueSlug(string $title): string
{
    $slug = translit($title);
    $original = $slug;
    $count = 1;
    while (static::where('slug', $slug)->exists()) {
        $slug = "{$original}-{$count}";
        $count++;
    }
    return $slug;
}

Routing

// Nested routes for hierarchy
Route::get('/catalog/{category}/{subcategory?}', [CatalogController::class, 'show'])
    ->where(['category' => '[a-z0-9\-]+', 'subcategory' => '[a-z0-9\-]+']);

Route::get('/catalog/{category}/{subcategory}/{product}', [ProductController::class, 'show'])
    ->where(['product' => '[a-z0-9\-]+']);

Permanent slug vs. generated from title

  • Fixed slug — doesn't change on title edit (SEO-preferable, no broken links)
  • Automatic — updates with title (needs automatic 301-redirect from old slug)

Store slug history for automatic 301s:

Schema::create('slug_redirects', function (Blueprint $table) {
    $table->string('old_slug')->primary();
    $table->string('new_slug');
    $table->string('model_type');
    $table->unsignedBigInteger('model_id');
    $table->timestamps();
});

URLs for multilingual sites

Structure options:

Structure Example
Subdomain ru.example.com/products/laptop
Path prefix example.com/ru/products/laptop
Separate domain example.ru/products/laptop

For Yandex, regional domains (.ru) are preferable. For Google — any option works if hreflang is set up.

Pagination

Preferred format: /blog/page/2 or /blog?page=2. Second variant is more convenient — doesn't require separate route, canonical is automatically correct.

Setup time: 1 day for slug system implementation with redirect history.