URL patterns for internationalization
Django offers internationalization capabilities for URLs. It includes two main features for internationalized URLs:
- A language prefix in URL patterns: Adding a language prefix to URLs to serve each language version under a different base URL
- Translated URL patterns: Translating URL patterns so that every URL is different for each language
One reason for translating URLs is to optimize your site for search engines. By adding a language prefix to your patterns, you will be able to index a URL for each language instead of a single URL for all of them. Furthermore, by translating URLs into each language, you will provide search engines with URLs that will rank better for each language.
Adding a language prefix to URL patterns
Django allows you to add a language prefix to your URL patterns. For example, the English version of your site can be served by a path starting with /en/
, and the Spanish version under /es/
....