I’ve tackled a similar setup before, and you're asking all the right questions. Since you're building the site from scratch without a CMS, you have a lot of flexibility—but also a few important decisions to make for long-term SEO and maintainability.
Here's what I'd recommend:
1. Static, crawlable URLs for each language
Search engines like Google, Bing, and Yandex prefer dedicated URLs per language, like:
example.com/en/
example.com/es/
example.com/fr/
This allows each version of your content to be indexed separately, and gives you control over language-specific SEO (title, meta tags, content, etc.). Avoid showing translated content dynamically with JavaScript or query strings like ?lang=fr, since that’s harder to index properly.
2. Avoid PHP-only translation with arrays (if SEO matters)
Your current array-based approach works fine for showing translations to users, but it’s not ideal for SEO. Search engines don’t “click around” or trigger server-side language functions like users do—they crawl static content tied to URLs.
If you use PHP arrays to serve content dynamically without creating static URLs per language, Google might only see the default version.
3. Use a database (like MySQL) for content and translations
This will give you much more flexibility, especially as your site grows and you add more languages. You can structure your database like this:
articles: id, slug, created_at
article_translations: article_id, language_code, title, body, meta_description, etc.
This way, you only need to add new rows when introducing a new language, and your code can handle rendering it dynamically based on the URL.
Same goes for menus, alt tags, etc. Just localize them in a translations table or structured file per language.
4. Don’t forget hreflang tags and lang attributes
To help search engines understand the relationship between language versions, use hreflang tags in the <head>:
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
Also set the lang attribute in your <html> tag appropriately for each version:
<html lang="en">
You can aslo read this blog to translate your website:https://www.pairaphrase.com/blog/best-way-translate-website-accuracy-seo