Skip to content

Commit c0f76bb

Browse files
Improve page metadata for sharing
- In _config.yml file: - Enable page excerpts - Set excerpt separator - In base layout: - Calculate title, description, URL in one place for meta tags - Always use page values for meta tags when present, fallback to site values - Replace conditional tags with single tag that uses calculated value - Move robots meta tag out from the middle of Open Graph tags - Reduce excessive whitespace from generated newlines - Add explicit excerpts to front matter of pages where automatic excerpt was not suitable / sufficient - Small adjustments to page first paragraphs to generate better description meta tags - Resolves swiftlang#203
1 parent 36aa0a3 commit c0f76bb

File tree

16 files changed

+57
-29
lines changed

16 files changed

+57
-29
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ timezone: America/Lower_Princes
55
exclude: ["README.md", "config.ru", "Gemfile", "Gemfile.lock", "Procfile", "vendor"]
66
safe: true
77
future: true
8+
excerpt_separator: <!--end excerpt-->
9+
page_excerpts: true
810

911
kramdown:
1012
syntax_highlighter: rouge

_layouts/base.html

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
4+
{%- if page.title -%}
5+
{%- capture meta_title -%}
6+
{{ page.title | escape }}
7+
{%- endcapture -%}
8+
{%- else -%}
9+
{%- assign meta_title = site.title -%}
10+
{%- endif -%}
11+
12+
{%- if page.excerpt -%}
13+
{%- capture meta_description -%}
14+
{{ page.excerpt | strip_html | strip | escape }}
15+
{%- endcapture -%}
16+
{%- else %}
17+
{%- assign meta_description = site.description -%}
18+
{%- endif -%}
19+
20+
{%- if page.url -%}
21+
{%- capture meta_url -%}
22+
{{ site.url }}{{ page.url }}
23+
{%- endcapture -%}
24+
{%- else -%}
25+
{%- assign meta_url = site.url -%}
26+
{%- endif %}
327

428
<head>
529
<meta charset="utf-8" />
@@ -10,7 +34,7 @@
1034
<meta name="author" content="Apple Inc." />
1135
<meta name="viewport" content="width=device-width initial-scale=1" />
1236
{% if page.excerpt %}
13-
<meta name="description" content="{{ page.excerpt | strip_html | escape }}">
37+
<meta name="description" content="{{ meta_description }}">
1438
{% endif %}
1539
<link rel="license" href="/LICENSE.txt" />
1640
<link rel="stylesheet" media="all" href="/assets/stylesheets/application.css" />
@@ -25,41 +49,33 @@
2549
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png" />
2650
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png" />
2751
<link rel="mask-icon" href="/assets/images/icon-swift.svg" color="#F05339" />
28-
{% if page.atom %}
52+
{%- if page.atom %}
2953
<link rel="alternate" type="application/atom+xml" title="Swift.org (Atom Feed)" href="/atom.xml" />
3054
{% endif %}
3155

32-
{% if page.url %}
56+
{%- if page.url -%}
3357
<link rel="canonical" href="{{ site.url }}{{ page.url }}" />
58+
{%- endif %}
59+
{% if page.robots %}
60+
<meta name="robots" content="{{page.robots}}" />
3461
{% endif %}
35-
3662
<meta name="twitter:card" content="summary" />
3763
<meta name="twitter:site" content="@SwiftLang" />
38-
{% if page.id %}
39-
<meta name="twitter:title" content="{{ page.title | escape }}" />
40-
<meta name="twitter:description" content="{{ page.excerpt | strip_html | escape }}" />
41-
{% else %}
42-
<meta name="twitter:title" content="{{ site.title }}" />
43-
<meta name="twitter:description" content="{{ site.description | strip_html | escape}}" />
44-
{% endif %}
64+
<meta name="twitter:title" content="{{ meta_title }}" />
65+
<meta name="twitter:description" content="{{ meta_description }}" />
4566

4667
<meta property="og:site_name" content="{{ site.title }}" />
4768
<meta property="og:image" content="{{ site.url }}/apple-touch-icon-180x180.png" />
48-
{% if page.robots %}
49-
<meta name="robots" content="{{page.robots}}" />
50-
{% endif %}
51-
{% if page.id %}
69+
{%- if page.id -%}
5270
<meta property="og:type" content="article" />
53-
<meta property="og:title" content="{{ page.title }}" />
54-
<meta property="og:url" content="{{ site.url }}{{ page.url }}" />
55-
<meta property="og:description" content="{{ page.excerpt | strip_html | escape }}" />
71+
{%- endif %}
72+
<meta property="og:title" content="{{ meta_title }}" />
73+
<meta property="og:url" content="{{ meta_url }}" />
74+
<meta property="og:description" content="{{ meta_description }}" />
75+
{%- if page.id %}
5676
<meta property="article:published_time" content="{{ page.date | date_to_xmlschema }}" />
5777
<meta property="article:modified_time" content="{{ site.time | date_to_xmlschema }}" />
58-
{% else %}
59-
<meta property="og:title" content="{{ site.title }}" />
60-
<meta property="og:url" content="{{ site.url }}" />
61-
<meta property="og:description" content="{{ site.description | strip_html | escape}}" />
62-
{% endif %}
78+
{%- endif %}
6379
</head>
6480

6581
<body>

blog/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: default
33
title: Blog
44
atom: true
5+
excerpt: "The Swift.org blog helps to keep the Swift community informed of recent developments in the language, the release roadmap, interesting new features, libraries, tools, as well as announcing project and community initiatives, and developer experiences."
56
---
67

78
{% for post in site.posts %}

documentation/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Documentation
4+
excerpt: "Whether you are new to Swift or an experienced Swift developer, documentation like The Swift Programming Language book, API Guidelines, and reference documentation for tools and libraries, serves as an invaluable resource in discovering all that Swift has to offer. "
45
---
56

67
If you are new to Swift, you may want to check out these additional resources.

download/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Download Swift
4+
excerpt: "Download both releases and development snapshots of Swift for all supported development platforms."
45
---
56

67

getting-started/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Getting Started
4+
excerpt: "Get started with the Swift programming language by downloading and installing the current version. From there you can explore interactively with the REPL. "
45
---
56

67
Here, you’ll find information about the how to use the Swift programming language.

server/guides/deployment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Deploying to Servers or Public Cloud
4+
excerpt: "Servers built with Swift can be deployed on a variety of public cloud providers. The guides listed on this page show you how."
45
---
56

67
The following guides can help with the deployment to public cloud providers:

server/guides/llvm-sanitizers.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ layout: page
33
title: LLVM TSAN / ASAN
44
---
55

6-
For multithreaded and low-level unsafe interfacing server code, the ability to use LLVM's [ThreadSanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html) and
7-
[AddressSanitizer](https://clang.llvm.org/docs/AddressSanitizer.html) can help troubleshoot invalid thread usage and invalid usage/access of memory.
6+
For multithreaded and low-level unsafe interfacing server code, the ability to use LLVM's [ThreadSanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html) and [AddressSanitizer](https://clang.llvm.org/docs/AddressSanitizer.html) can help troubleshoot invalid thread usage and invalid usage/access of memory.
87

98
There is a [blog post](/blog/tsan-support-on-linux/) outlining the usage of TSAN.
109

server/guides/memory-leaks-and-usage.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ layout: page
33
title: Debugging Memory Leaks and Usage
44
---
55

6-
There are many different tools for troubleshooting memory leaks both on Linux and macOS, each with different strengths and ease-of-use. One excellent tool is the Xcode's [Memory Graph Debugger](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html#//apple_ref/doc/uid/TP40015022-CH9-DontLinkElementID_1).
7-
[Instruments](https://help.apple.com/instruments/mac/10.0/#/dev022f987b) and `leaks` can also be very useful. If you cannot run or reproduce the problem on macOS, there are a number of server-side alternatives below.
6+
There are many different tools for troubleshooting memory leaks both on Linux and macOS, each with different strengths and ease-of-use. One excellent tool is the Xcode's [Memory Graph Debugger](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html#//apple_ref/doc/uid/TP40015022-CH9-DontLinkElementID_1). [Instruments](https://help.apple.com/instruments/mac/10.0/#/dev022f987b) and `leaks` can also be very useful. If you cannot run or reproduce the problem on macOS, there are a number of server-side alternatives below.
87

98
## Example program
109

server/guides/performance.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ layout: page
33
title: Debugging Performance Issues
44
---
55

6-
First of all, it's very important to make sure that you compiled your Swift code in _release mode_. The performance difference between debug and release builds is huge in Swift. You can compile your Swift code in release mode using
6+
First of all, it's very important to make sure that you compiled your Swift code in _release mode_. The performance difference between debug and release builds is huge in Swift.
7+
8+
You can compile your Swift code in release mode using:
79

810
swift build -c release
911

server/guides/setup-and-ide-alternatives.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Installing Swift and using with IDEs
4+
excerpt: "Swift is supported on a number of platforms, integrated development environments (IDEs), and editors."
45
---
56

67
## Installing Swift

server/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
redirect_from: "/server-apis/"
33
layout: page
44
title: Swift on Server
5+
excerpt: "Swift has unique characteristics that make it specifically suitable for Server applications, including a small memory footprint, fast startup times, and deterministic performance."
56
---
67

78
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

sswg/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: page
33
title: Swift Server Workgroup (SSWG)
44
---
55

6-
The Swift Server workgroup is a steering team that promotes the use of Swift for developing and deploying server applications. The Swift Server workgroup will:
6+
The Swift Server workgroup is a steering team that promotes the use of Swift for developing and deploying server applications. <!--end excerpt--> The Swift Server workgroup will:
77

88
* Define and prioritize efforts that address the needs of the Swift server community
99
* Define and run an incubation process for these efforts to reduce duplication of effort, increase compatibility and promote best practices

website-governance/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Swift.org website governance
4+
excerpt: "The Swift.org website has group of maintainers which includes a subset of the Swift core team and the Swift website workgroup members. The maintainers are in charge of reviewing and merging pull requests from contributors. The Swift.org website source code consists of several distinct parts. Each one of these areas is governed by a slightly different contribution process that matches their nature."
45
---
56

67
See [website overview](/website) for more information about the Swift.org website goals and contribution guidelines.

website-workgroup/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Swift.org website workgroup (SWWG)
4+
excerpt: "The Swift website workgroup is a steering team that helps guide the evolution on the Swift.org website."
45
---
56

67
See [website overview](/website) for more information about the Swift.org website goals, content governance and contribution guidelines.

website/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: page
33
title: Swift.org website
4+
excerpt: "Swift.org is the website of the Swift programming language providing newcomers and experienced developers with documentation, announcements, and news about Swift and the Swift community in a safe, friendly environment."
45
---
56

67
Swift.org website goals include:

0 commit comments

Comments
 (0)