Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hreflang Tag to Translation Link example #2396

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

ZhangChengLin
Copy link
Contributor

@ZhangChengLin ZhangChengLin marked this pull request as ready for review January 10, 2024 15:20
@jmooring
Copy link
Member

I suggest this instead:


  <ul>
    {{ range . }}
      {{ $langName := or .Language.LanguageName .Language.Lang }}
      {{ $langCode := or .Language.LanguageCode .Language.Lang }}
      <li><a href="{{ .RelPermalink }}" hreflang="{{ $langCode }}">{{ .LinkTitle }} ({{ $langName }})</a></li>
    {{ end }}
  </ul>

The language config may not contain either .LanguageName or .LanguageCode.

@ZhangChengLin
Copy link
Contributor Author

I suggest this instead:


  <ul>
    {{ range . }}
      {{ $langName := or .Language.LanguageName .Language.Lang }}
      {{ $langCode := or .Language.LanguageCode .Language.Lang }}
      <li><a href="{{ .RelPermalink }}" hreflang="{{ $langCode }}">{{ .LinkTitle }} ({{ $langName }})</a></li>
    {{ end }}
  </ul>

The language config may not contain either .LanguageName or .LanguageCode.

I did write it like you did at first, but later I found that based on the context configured in this page of the document, the current way of writing should be enough.
I do think the way you provided is more complete, and I would like to write it that way in my own site code.
If you think that's the only way to accept a PR, I'm willing to adjust.

@jmooring
Copy link
Member

Please make the change as suggested.

@ZhangChengLin
Copy link
Contributor Author

Please make the change as suggested.

The modifications have been completed according to the suggested writing method.

@jmooring
Copy link
Member

Thank you.

@jmooring jmooring merged commit 9a64d95 into gohugoio:master Jan 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants