Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Philip Hayton 98 posts 435 karma points
    May 02, 2019 @ 20:20
    Philip Hayton
    0

    Accessing Content Variants via UmbracoCache.GetByRoute

    Hi guys,

    I'm building a content API for a multi lingual site. We decided to go with a subfolder setup for each language. For example:

    Default: mydomain.com/things-to-do/

    Spanish: mydomain.com/es/cosas-para-hacer/

    French: mydomain.com/fr/choses-a-faire/

    This URL structure works fine when navingating to the page in a browser. However, using ContentCache.GetByRoute("/fr/") doesn't return any content, and neither does ContentCache.GetByRoute("/fr/", culture = "fr-FR").

    Any ideas what I'm doing wrong?

    As a side note; I noticed the following warning on the Cultures and Hostname panel:

    One-level paths in domains are supported, eg. "example.com/en". However, they should be avoided. Better use the culture setting above.

    ...but it doesn't explain why they should be avoided (it's my understanding that this is common SEO practice). This warning is a bit vague, can any elaborate?

    Any help is greatly appreciated. TIA!

    Kind regards

  • Philip Hayton 98 posts 435 karma points
    May 10, 2019 @ 15:23
    Philip Hayton
    0

    Minor update; I've had a dive into the source code and in the GetByRouteInternal method it again states:

    // if in a domain then start with the root node of the domain
    // and follow the path
    // note: if domain has a path (eg example.com/en) which is not recommended anymore
    //  then /en part of the domain is basically ignored here...
    

    Can anyone shed any light on why this is not recommended? Is it a technical issue with Umbraco? Or is Umbraco imposing some kind of opinions on us?

    From the reasearch I've done, this seems to be the recommended way to structure multi-lingual sites these days.

Please Sign in or register to post replies

Write your reply to:

Draft