Jump to content

[SOLVED] Force default home page


Angelino
 Share

Recommended Posts

  • Angelino changed the title to Force default home page

Some answers from Google: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites

Quote

Use different URLs for different language versions

Google recommends using different URLs for each language version of a page rather than using cookies or browser settings to adjust the content language on the page.

If you use different URLs for different languages, use hreflang annotations to help Google search results link to the correct language version of a page.

If you prefer to dynamically change content or reroute the user based on language settings, be aware that Google might not find and crawl all your variations. This is because the Googlebot crawler usually originates from the USA. In addition, the crawler sends HTTP requests without setting Accept-Language in the request header.

 

Link to comment
Share on other sites

I have also a dropdown switch

 <?php

  $homepage = $pages->get( '/' );

  $langswitch = '';
  foreach ( $languages as $language ) {
    if ( !$page->viewable( $language ) ) continue; // is page viewable in this language?
    if ( $language->id == $user->language->id ) { // current user language
      $langswitch .= "<div class='current'>";
    } else {
      $langswitch .= "<div>";
    }
    $url = $page->localUrl( $language );
    $hreflang = $homepage->getLanguageValue( $language, 'name' );
    $langswitch .= "<a hreflang='x-default' href='$url' title='{$language->title}'>{$language->title}<div class='{$language->name}'></div></a></div>";
  }
  echo "<div class='dropdown'> 
         <div class='{$user->language->name}' title='Language'></div>
        <div class='language-switch-ph' style='display:none;'>{$langswitch}</div>
        </div>";
  ?>

 

Link to comment
Share on other sites

First: define the matching /name/ for each language in your homepage

2023-10-02_18-23.thumb.png.62b315a36b0baa65acf81b748a0aee72.png

Second: Go to Modules > Core > Languages Support - Page Names > Settings and define the behaviour

2023-10-02_18-21.thumb.png.d8e64e1e6a4c404f26c229eae4d8ef12.png

 

This way the homepage will redirect to your specified default language /name/ if set.
It won't redirect from /nl/ or /es/ back to the default one.

In case you want to switch to another language as the default one - take a look here:

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

  • Angelino changed the title to [SOLVED] Force default home page

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...