#what do hrefLang and lang properties do

1 messages · Page 1 of 1 (latest)

kindred igloo
short moatBOT
#

Hi @kindred igloo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

kindred igloo
#

@short moat

short moatBOT
#

Sorry @kindred igloo, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @kindred igloo, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

kindred igloo
#

@short moat what do hrefLang and lang properties do on next/link?

short moatBOT
#

Let me check the knowledge base for you. One moment! :books:

#

The hrefLang and lang properties are not directly used with next/link. However, they are related to internationalization in Next.js.

The lang attribute is automatically added to the <html> tag by Next.js when it knows the language the user is visiting. This helps with accessibility and search engine optimization.

The hreflang attribute is not directly used with next/link, but it's important for internationalized websites. You need to add hreflang meta tags using next/head to inform search engines about the different language versions of a page. You can learn more about hreflang in the Google Webmasters documentation (https://support.google.com/webmasters/answer/189077).

To transition between locales in Next.js, you can use the locale prop with next/link or specify the locale in the transition options when using next/router. Here's an example using next/link:

import Link from 'next/link'

export default function IndexPage(props) {
  return (
    <Link href="/another" locale="fr">
      To /fr/another
    </Link>
  )
}

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Next.js has built-in support for internationalized routing and language detection. Learn more here.