_includes/alternates/alternates.html in word-games-theme-2.9.2 vs _includes/alternates/alternates.html in word-games-theme-2.9.3

- old
+ new

@@ -4,15 +4,30 @@ {%- for i in matchurls -%} {%- for checklang in site.pages -%} {%- if checklang.permalink == i -%} {%- assign languagetext = [i] -%} + +{% assign whitelist_urls = site.whitelist_urls %} {% if site.noindex_languages contains languagetext[0] %} +{%- if whitelist_urls -%} +{% for url in whitelist_urls %} +{% assign current_url = url | remove_first: '/' | strip %} +{% assign language_url = languagetext[0] | strip %} +{% if current_url == language_url %} +{%- assign exclude_url = true -%} +{% endif %} +{% endfor %} +{%- if exclude_url -%} +<link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> +{%- endif -%} +{%- endif -%} {%- else -%} <link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> {%- endif -%} + {%- endif -%} {%- endfor -%} {%- endfor -%} {%- else -%} @@ -22,51 +37,106 @@ <link data-rh="true" rel="alternate" href="{{site.url}}" hreflang="en" /> {%- for i in matchurls -%} {%- assign languagetext = [i] -%} {%- if i== page.permalink -%} +{% assign whitelist_urls = site.whitelist_urls %} {% if site.noindex_languages contains languagetext[0] %} +{%- if whitelist_urls -%} +{% for url in whitelist_urls %} +{% assign current_url = url | remove_first: '/' | strip %} +{% assign language_url = languagetext[0] | strip %} +{% if current_url == language_url %} +{%- assign exclude_url = true -%} +{% endif %} +{% endfor %} +{%- if exclude_url -%} +<link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> +{%- endif -%} +{%- endif -%} {%- else -%} -<link data-rh="true" rel="alternate" href="{{site.url}}{{page.permalink}}" hreflang="{{languagetext[0]}}" /> +<link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> {%- endif -%} + {%- else -%} + {%- for checklang in site.pages -%} {%- if checklang.permalink == i -%} {%- assign languagetext = [i] -%} {% if site.noindex_languages contains languagetext[0] %} +{%- if whitelist_urls -%} +{% for url in whitelist_urls %} +{% assign current_url = url | remove_first: '/' | strip %} +{% assign language_url = languagetext[0] | strip %} +{% if current_url == language_url %} +<link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> +{% endif %} +{% endfor %} +{%- endif -%} {%- else -%} <link data-rh="true" rel="alternate" href="{{site.url}}/{{languagetext[0]}}" hreflang="{{languagetext[0]}}" /> {%- endif -%} - {%- endif -%} {%- endfor -%} {%- endif -%} {%- endfor -%} {%- else -%} + {%- for item in site.pages -%} {%- assign languagetext = [item.lang] -%} {%- assign pagelink = page.permalink | split: "/" | last-%} {%- assign itemlink = item.permalink | split: "/" | last-%} -{%- if pagelink == itemlink and page.lang != item.lang and page.permalink != -item.permalink -%} +{%- if pagelink == itemlink and page.lang != item.lang and page.permalink != item.permalink -%} {% if site.noindex_languages contains languagetext[0] %} +{%- if whitelist_urls -%} +{% for url in whitelist_urls %} +{% assign current_url = url | strip %} +{% if current_url == item.permalink %} +<link data-rh="true" rel="alternate" href="{{site.url}}{{item.permalink}}" hreflang="{{languagetext[0]}}" /> +{% endif %} +{% endfor %} +{%- endif -%} {%- else -%} <link data-rh="true" rel="alternate" href="{{site.url}}{{item.permalink}}" hreflang="{{languagetext[0]}}" /> {%- endif -%} +{%- endif -%} -{%- endif -%} {%- if pagelink == itemlink and page.lang == item.lang -%} - +{% assign whitelist_urls = site.whitelist_urls %} {% if site.noindex_languages contains languagetext[0] %} -{%- else -%} +{%- if whitelist_urls -%} +{% for url in whitelist_urls %} +{% assign current_url = url | strip %} +{% if current_url == item.permalink %} +{%- assign exclude_url = true -%} +{% endif %} +{% endfor %} +{%- if exclude_url -%} <link data-rh="true" rel="alternate" href="{{site.url}}{{item.permalink}}" hreflang="{{languagetext[0]}}" /> {%- endif -%} +{%- endif -%} +{%- else -%} + +{% assign final_permalink = item.permalink %} +{% if item.permalink contains '/' %} +{% else %} + {% assign final_permalink = '/' | append: item.permalink %} +{% endif %} + +{%- if site.blacklist_urls contains final_permalink -%} +{%- else -%} +<link data-rh="true" rel="alternate" href="{{ site.url }}{{final_permalink}}" hreflang="{{ languagetext[0] }}" /> {%- endif -%} + + +{%- endif -%} +{%- endif -%} + {%- endfor -%} {%- endif -%} {%- endif -%} \ No newline at end of file