jekyll / jekyll-seo-tag

A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
https://jekyll.github.io/jekyll-seo-tag
MIT License
1.66k stars 294 forks source link

i18n Support via Polyglot #504

Open ctsstc opened 8 months ago

ctsstc commented 8 months ago

I've been using https://github.com/untra/polyglot as it seems to be the last maintained i18n implementation.

Since I'm rather new to Jekyll, it seems that you cannot utilize dynamic variables in front matter since it's utilized for static content. I did find this random comment that was related 😆 https://github.com/jekyll/jekyll-seo-tag/issues/494#issuecomment-1675157934

My Example

I've been defining i18n content in /_data/en/pages/some_page.yml

I'm then able to pull the content in a template like so and have it pull the current language from the data definitions.

---
title: Some Page
---
{% assign t = site.data.pages.some_page %}
<div>
  <h1>{{ t.header}}</h1>
  <p>{{ t.sub_title }}</p>
</div>

Proposal

I'm not sure if something like this would be possible since you cannot put dynamic content into the front matter, but it could surely help the situation if we could do something like this instead:

{% assign t = site.data.pages.some_page %}
{% assign title = t.title %}
<div>
  <h1>{{ t.header}}</h1>
  <p>{{ t.sub_title }}</p>
</div>

I'm really hoping something like this would be possible 🤞