Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Add lang attribute and hreflang meta tags #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gluegun.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_runtime_dependency 'github-markdown', "~> 0"
spec.add_runtime_dependency "iso-639", "~> 0.2.5"
end
8 changes: 5 additions & 3 deletions lib/_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@
</div>
</div>

<% if !@site_map['Language'].nil? %>
<% if !@site_map['Languages'].nil? %>
<div class="dropdown">
<a href="" class="dropdown__toggle dropdown__toggle--caret doc-actions__item">
<img src="/<%=@site_map['Output']%>/img/icons/translate.svg" alt="">
<span>Translation</span>
</a>

<div class="dropdown__menu dropdown__menu--right">
<%- @site_map['Language'].each do |categories| -%>
<%- @site_map['Languages'].each do |categories| -%>
<%- categories.each do |key, value| -%>
<a class="dropdown__item" href="<%=value -%>"><%= key -%></a>
<%- unless key == @site_map['Language']%>
<a class="dropdown__item" href="<%=value -%>"><%= key -%></a>
<%- end -%>
<%- end -%>
<%- end -%>
</div>
Expand Down
1 change: 1 addition & 0 deletions lib/gluegun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'github/markdown'
require 'erb'
require 'fileutils'
require 'iso-639'

module Gluegun

Expand Down
10 changes: 9 additions & 1 deletion lib/index.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="<%= ISO_639.find_by_english_name(@site_map['Language']).alpha2 %>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Expand All @@ -17,6 +17,14 @@
<%- end -%>
<meta name="description" content="<%= key2["SEO Description"] %>">
<meta name="keywords" content="<%= key2["SEO Keywords"] %>">

<%- if !@site_map['Languages'].nil? && !key2["SEO Languages"].nil? -%>
<link rel="alternate" hreflang="<%= ISO_639.find_by_english_name(@site_map['Language']).alpha2 %>" href="<%=@site_map['Languages'][@site_map['Language']]%>/<%=key2["Slug"]%>.html" title="lang">

<% key2["SEO Languages"].each do |lang| %>
<link rel="alternate" hreflang="<%= ISO_639.find_by_english_name(lang).alpha2 %>" href="<%=@site_map['Languages'][lang]%>/<%=key2["Slug"]%>.html" title="lang">
<% end %>
<%- end -%>
<%- else -%>
<%-# Take first entry specified under the 'Documents' key for index page-%>
<%- if !@site_map['Documents'][0].values[0][0]["SEO Title"] -%>
Expand Down
10 changes: 7 additions & 3 deletions site-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Site: "Site Title" # Requir
Output: "docs" # Required - Output directory where html files are generated
Logo: "https://<domain.com>/url-to-logo.svg" # Site Branding
SEO Author: "Author Name" # Optional - Meta author tag for SEO
Language: "English" # Required - Language of the docs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it might be a good idea to indicate (either on the key name or the comment for this field) that this is the current language of the docs for the pages listed in this yml file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaankabalak will update the comment to convey it correctly, thanks


Language: # Optional - Translation links
- Chinese: https://<domain.com>/cn
- Japanese: https://<domain.com>/jp
Languages: # Optional - Translation links
English: https://<domain.com>/en
Chinese: https://<domain.com>/cn
Japanese: https://<domain.com>/jp

Plugins: # Optional - Plugins (Algolia for search and Google Analytics)
- Algolia:
Expand All @@ -23,6 +25,8 @@ Documents: # Requir
SEO Title: "Document Title" # Optional - Page title tag
SEO Description: "Description" # Optional - Meta description tag for SEO
SEO Keywords: "keyword1, keyword2, keyword3" # Optional - Meta keywords tag for SEO
SEO Languages: # Optional - Transaltions for SEO
- Chinese
Options: hidden # Optional - The value 'hidden' allows user to render page but hide sidebar link


Expand Down
10 changes: 7 additions & 3 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ Site: "Gluegun"
Output: "docs"
Logo: "https://min.io/resources/img/logo/black-logo.svg"
SEO Author: "MinIO"
Language: "English"

Language:
- Chinese: https://gluegun.minio.io/cn
- Japanese: https://gluegun.minio.io/jp
Languages:
English: "https://gluegun.minio.io/en"
Chinese: https://gluegun.minio.io/cn
Japanese: https://gluegun.minio.io/jp

Plugins:
- Algolia:
Expand All @@ -25,6 +27,8 @@ Documents:
SEO Title: "Gluegun | Quick Start Guide"
SEO Description: "Learn how to get started with Gluegun."
SEO Keywords: "Gluegun, generate documentation, MinIO"
SEO Languages:
- Chinese

- Theming:
- Gluegun Theming Guide:
Expand Down