Setting the front page per language

When a user comes to your site via yourdomain.com you want to direct them to the front page. When they come to your site via yourdomain.com/es you want to direct them to the Spanish front page.

In order to do this, you need to set the path to the home page node. That path must be the same for all language versions of the home page.

Then, go to the Site information admin page and set that path as the Default front page. Here is how to do this, step by step.

1) Edit the node for your home page and set the path url - example: try setting it to "home"

2) Do the same on the Spanish node that you want to be your home page and set the path url to the same value, "home" in this example.

3) Go to your Site information page /admin/settings/site-information and set the front page to the same as the URL path - "home" in this example.

front page

4) Save the configuration and test your urls.

 

You can see it in action on this site:

 


 

Update:

You may get the following warning:

user warning: Duplicate entry 'home-es' for key 2 query: UPDATE url_alias SET src = 'node/126', dst = 'home', language = 'es' WHERE dst = 'home' in /home/bruce/drupal/drupal-6.13/modules/path/path.module on line 108.

This appears to occur if you have already used the alias before but on a language neutral page.

You can try editing the url aliases directly at /admin/build/path. Search for your alias name and delete the alias if the languages is showing "All".

Comments

default language

Hi, I'm experiencing a problem with my default language.

I have a multi-language Drupal site with BG (Bulgarian) and EN (English). Everything seems to work fine except the default language for my home page (en/home and bg/home). I read what to do in the How-to guide in Common questions, but the solution described there won't work for me.

Is rewriting the address with .htaccess my only option ?

Thanks.

Solution

Hi,

I have experienced the same problem and I managed to solve it by specifying prefix for both languages. Then I have edited site info for:

English:
example.com/en/admin/settings/site-information
and specified -Default front page:
example.com/en/ node/7 (number of home English)

and Polish:
example.com/pl /admin/settings/site-information
and specified -Default front page:
example.com/en/ node/11 (number of home Polish)

default path prefix

i am trying to solve a related problem and wonder if you could help.

except for auto redirection to the default language path prefix, my multilingual configuration works properly.

if i go to www.example.com, it won't switch to the default language path prefix on its own. it is always english, while english is set up as www.example.com/en like any other language and it is not the default one.

i could solve it of course through .htaccess rewrite rules if i used "language domain" rather than "path prefix", but this option is buggy and adds many redundant prefixes to the path.

really hope you have an idea. cheers, monti

Language Switcher fails on homepage

Another problem is with the language switcher. Using the translation links on a node I translated to 2 other languages works. Also the menu links change correctly. Now though if I click on the language on the language switcher it fails to work. I noticed that for the page set as the main page ( with the default language content ) the language switcher does not link to the correct translation pages but to http://yourhost without the correct path afterwards. Looks like for the node set as the default page the language switcher messes up and fails to output the correct links. If I am on a translated version of the same node the language switcher does show the correct links. Any ideas on what could cause this?

Does not work

Does not work here for some reason. Following the steps but when I use yourhost/de or any other language prefix I get 404 error. Anything particular you have to enable to get this working outside of what you mentioned on this page?

It could be something to do with the language negotiation

Go to /admin/settings/language/configure and set the negotiation to path prefix only or path prefix with language fallback.

I did that but it's still not

I did that but it's still not working ( getting 404 )

404 Error - Solution

Finally I found the solution for the 404 error.

The default frontpage nees to be applied for EACH language (didnt know that). In my case for:

---> admin/settings/site-maintenance
---> /en/admin/settings/site-maintenance
---> /es/admin/settings/site-maintenance

regards
hilrap

Solution for 404 error?

Same me! mydomain.com/en and mydomain.com/es respectively, will give me 404 error (page not found). My default language is German (without any prefix)...
Has there been any solution for this ?

Much appreciated!! :-)

Beware of English path prefix!

First of all, big thanks for your write up, this helped a lot!

I did have one strange thing, I have a site in 3 languages, Dutch, French and English, with Dutch the default language. After I applied your suggestions, the front page language switcher worked for Dutch and French, but not for English. After some trail and error, I found out that by default the path prefix for English is empty. Changing this to "en" made the language switcher on the front page work for Engish too.

Thanks.
Nick.

It does not work with more than one page to be promoted to front

Thanks, this is a great solution.

But, what happens when we have more than one page promoted page?

You don't need a homepage

I had the same problem, but I seem to have figured it out, at least for my site.

I set up an url alias with the system path as 'node' for all languages.

Then I added the alias /home

Whenever you reference 'home' it just points at the standard frontpage.

My problem was going from the homepage to a section in my site.
Then I would switch the language and click back to the homepage.

When I got to the homepage, despite the url reading /en (my default is /ja )the links would not include the English prefix.

This fixed it.
However this is a mobile site and I am referencing the homepage via the header image which I have point at the homepage in the page.tpl template.


language.'/home'; ?>"" >
/>

So it might not be for everyone.

This was driving me crazy -

This was driving me crazy - thanks a lot for this article, it worked flawlessly.

SQL error

hello,

by strictly following these steps,
i got this error :

user warning: Duplicate entry 'home-fr' for key 2 query: UPDATE vt_url_alias SET src = 'node/2', dst = 'home', language = 'fr' WHERE dst = 'home' in /homez.184/legren/www/vt_dp/modules/path/path.module on line 108.

what bugs me is the "WHERE dst='home'", whereas you wrote that it was ok for naming both english & foreign urls as "home".

do you have a hint please ?

Can you try this patch

http://drupal.org/node/269877#comment-1338984

There is a lot of discussion about this problem here: http://drupal.org/node/269877

Let us know if this fixes it for you.

Works well

thanks a lot, it works perfectly !
opi

duplicate path

Drupal reported duplicate path while configuring the same url alias of both languages.

path settings

You may need to activate the path module in order to access URL path settings when editing nodes.

Right, the path module needs to be active

Drupal depends on the path module in order to set 'fancy' paths to nodes, so it must be enabled for this to work.

How?

Where do I find this URL path settings, as seen in step 1?

"The path is already in use." error

Hi

I tried to follow this advice but wasn't surprised to find that Drupal will not accept a URL alias that is already in use.

Am I misunderstanding in some way ?

Thanks

Dave

You get "The path is already

You get "The path is already in use." error if you don't turn on multilingual support for the content type. Go to admin->settings->content type. Choose page for example and turn on the multilingual support under Workflow Settings