Merge pull request #1409 from influxdata/canonical-override

Canonical override
pull/1412/head
Scott Anderson 2020-09-08 16:29:23 -06:00 committed by GitHub
commit eac3adae0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 5 deletions

View File

@ -75,6 +75,7 @@ list_code_example: # Code example included with article descriptions in children
list_query_example: # Code examples included with article descriptions in children type="articles" shortcode,
# References to examples in data/query_examples
products: # List of products that the page specifically applies to: [oss, cloud, enterprise]
canonical: # Path to canonical page, overrides auto-gen'd canonical URL
```
#### Title usage
@ -644,6 +645,25 @@ Redoc generates HTML documentation using the InfluxDB `swagger.yml`.
For more information about generating InfluxDB API documentation, see the
[API Documentation README](https://github.com/influxdata/docs-v2/tree/master/api-docs#readme).
## Canonical URLs
Search engines use canonical URLs to accurately rank pages with similar or identical content.
The `canonical` HTML meta tag identifies which page should be used as the source of truth.
By default, canonical URLs are automatically generated for each page in the InfluxData
documentation using the latest version of the current product and the current path.
Use the `canonical` frontmatter to override the auto-generated canonical URL.
_**Note:** The `canonical` frontmatter supports the [`{{< latest >}}` shortcode](#latest-links)._
```yaml
canonical: /path/to/canonical/doc/
# OR
canonical: /{{< latest "influxdb" "v2" >}}/path/to/canonical/doc/
```
## InfluxDB URLs
When a user selects an InfluxDB product and region, example URLs in code blocks
throughout the documentation are updated to match their product and region.

View File

@ -6,6 +6,7 @@ menu:
influxdb_1_3:
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---

View File

@ -6,6 +6,7 @@ menu:
influxdb_1_4:
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---

View File

@ -7,6 +7,7 @@ menu:
name: Line Protocol reference
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---

View File

@ -7,6 +7,7 @@ menu:
name: Line Protocol reference
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---

View File

@ -7,6 +7,7 @@ menu:
name: InfluxDB line protocol reference
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---
InfluxDB line protocol is a text based format for writing points to InfluxDB.
@ -201,12 +202,12 @@ In field values, you must use a backslash character (`\`) to escape:
- the backslash character itself (`\`).
For example, `\"` escapes a double quote.
>#### Note on backslashes:
>
* If you use multiple backslashes, they must be escaped. Influx interprets backslashes as follows:
* `\` or `\\` interpreted as `\`
* `\\\` or `\\\\` interpreted as `\\`
* `\` or `\\` interpreted as `\`
* `\\\` or `\\\\` interpreted as `\\`
* `\\\\\` or `\\\\\\` interpreted as `\\\`, and so on
In tag keys, tag values, and field keys, you must escape:

View File

@ -9,6 +9,7 @@ menu:
name: InfluxDB line protocol reference
weight: 10
parent: Write protocols
canonical: /{{< latest "influxdb" "v2" >}}/reference/syntax/line-protocol/
---
InfluxDB line protocol is a text-based format for writing points to InfluxDB.

View File

@ -17,8 +17,32 @@
{{ $baseURL := replaceRE `\/$` "" .Site.BaseURL }}
{{ $scratch.Set "canonicalURL" (print $baseURL .RelPermalink) }}
{{ if ge (len (findRE "[^/]+.*?" .RelPermalink)) 2 }}
{{ $scratch.Set "canonicalURL" (print $baseURL (replaceRE `v[0-9]\.[0-9]{1,2}` $latestMinorVersion .RelPermalink))}}
<!-- Override canonical URL with 'canonical' frontmatter, support latest shortcode -->
{{ if .Page.Params.canonical }}
{{ if in .Page.Params.canonical "{{< latest" }}
{{ $product := replaceRE `[ \"]` "" (index (findRE ` \"\w*\"` .Page.Params.canonical) 0) }}
{{ $majorVersion := replaceRE `[ \"]` "" (index (findRE ` \"\w*\"` .Page.Params.canonical) 1) }}
{{ $minorVersions := (index $.Site.Data.products $product).versions }}
{{ $scratch.Set "latestVersion" (index $.Site.Data.products $product).latest }}
{{ if gt (len $majorVersion) 0 }}
{{ if eq $majorVersion "v1" }}
{{ $scratch.Set "latestVersion" (index (last 1 (findRE `v1\.[0-9]{1,2}` (delimit $minorVersions " "))) 0) }}
{{ else if eq $majorVersion "v2" }}
{{ $scratch.Set "latestVersion" (index (last 1 (findRE `v2\.[0-9]{1,2}` (delimit $minorVersions " "))) 0) }}
{{ end }}
{{ end }}
{{ $productLatestVersion := $scratch.Get "latestVersion" }}
{{ $replaceLatest := replaceRE `\{\{\< latest \".*\" \>\}\}` (print $product "/" $productLatestVersion) .Page.Params.canonical }}
{{ $scratch.Set "canonicalURL" (print $baseURL $replaceLatest) }}
{{ else }}
{{ $scratch.Set "canonicalURL" (print $baseURL .Page.Params.canonical) }}
{{ end }}
{{ else if ge (len (findRE "[^/]+.*?" .RelPermalink)) 2 }}
{{ $scratch.Set "canonicalURL" (print $baseURL (replaceRE `v[0-9]\.[0-9]{1,2}` $latestMinorVersion .RelPermalink)) }}
{{ end }}
{{ $canonicalURL := $scratch.Get "canonicalURL" }}