mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-04-06 07:46:05 +00:00
seo/geo
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
{{/* Enhanced breadcrumb with Schema.org markup for better SEO */}}
|
||||
{{ if not .Params.disableBreadcrumb }}
|
||||
{{ $ancestors := slice }}
|
||||
{{ $current := . }}
|
||||
{{ range $current.Ancestors.Reverse }}
|
||||
{{ $ancestors = $ancestors | append . }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $ancestors }}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": [
|
||||
{{ range $index, $ancestor := $ancestors }}
|
||||
{
|
||||
"@type": "ListItem",
|
||||
"position": {{ add $index 1 }},
|
||||
"name": "{{ $ancestor.Title }}",
|
||||
"item": "{{ $ancestor.Permalink }}"
|
||||
}{{ if ne $index (sub (len $ancestors) 1) }},{{ end }}
|
||||
{{ end }}
|
||||
,{
|
||||
"@type": "ListItem",
|
||||
"position": {{ add (len $ancestors) 1 }},
|
||||
"name": "{{ .Title }}",
|
||||
"item": "{{ .Permalink }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -19,9 +19,6 @@
|
||||
<link rel="alternate" hreflang="x-default" href="{{ $xDefault }}" />
|
||||
{{- end }}
|
||||
|
||||
<!-- Enhanced breadcrumb structured data -->
|
||||
{{- partial "breadcrumb-seo.html" . -}}
|
||||
|
||||
<!-- Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WCJMDEZ618"></script>
|
||||
<script>
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{- end -}}
|
||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||
{{ with .Lastmod }}<meta property="og:updated_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
|
||||
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
||||
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{{- $siteDescription := .Site.Params.description | plainify | htmlUnescape | chomp -}}
|
||||
{{- $description := partial "utils/page-description.html" . | plainify | htmlUnescape | chomp -}}
|
||||
{{- $softwareDescription := partial "utils/software-description.html" . | plainify | htmlUnescape | chomp -}}
|
||||
{{- $faqItems := partial "utils/faq-schema-items.html" . -}}
|
||||
{{- $howToItems := partial "utils/howto-schema-items.html" . -}}
|
||||
{{- $breadcrumb := partial "utils/breadcrumb-schema-object.html" . -}}
|
||||
{{- $tocItems := partial "utils/toc-schema-items.html" . -}}
|
||||
{{- $videoItems := partial "utils/video-schema-items.html" . -}}
|
||||
|
||||
{{- $keywords := .Params.keywords | default .Site.Language.Params.keywords | default .Site.Params.keywords -}}
|
||||
{{- $imageURL := "" -}}
|
||||
@@ -15,19 +20,26 @@
|
||||
{{- $orgID := "https://rustdesk.com/#organization" -}}
|
||||
{{- $websiteID := printf "%s#website" .Site.Home.Permalink -}}
|
||||
{{- $pageID := printf "%s#webpage" .Permalink -}}
|
||||
{{- $faqID := printf "%s#faq" .Permalink -}}
|
||||
{{- $tocID := printf "%s#toc" .Permalink -}}
|
||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||
|
||||
{{- $orgSameAs := slice
|
||||
"https://github.com/rustdesk"
|
||||
"https://twitter.com/rustdesk"
|
||||
"https://discord.com/invite/nDceKgxnkV"
|
||||
"https://www.reddit.com/r/rustdesk/"
|
||||
-}}
|
||||
{{- with .Site.Params.social.youtube -}}
|
||||
{{- $orgSameAs = $orgSameAs | append (printf "https://youtube.com/@%s" .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $org := dict
|
||||
"@type" "Organization"
|
||||
"@id" $orgID
|
||||
"name" "RustDesk"
|
||||
"url" "https://rustdesk.com"
|
||||
"sameAs" (slice
|
||||
"https://github.com/rustdesk"
|
||||
"https://twitter.com/rustdesk"
|
||||
"https://discord.com/invite/nDceKgxnkV"
|
||||
"https://www.reddit.com/r/rustdesk/"
|
||||
)
|
||||
"sameAs" $orgSameAs
|
||||
"contactPoint" (dict
|
||||
"@type" "ContactPoint"
|
||||
"contactType" "Support"
|
||||
@@ -47,6 +59,18 @@
|
||||
"publisher" (dict "@id" $orgID)
|
||||
"inLanguage" .Site.Language.Lang
|
||||
-}}
|
||||
{{- if (site.Params.search.enable | default true) -}}
|
||||
{{- $website = merge $website (dict
|
||||
"potentialAction" (dict
|
||||
"@type" "SearchAction"
|
||||
"target" (dict
|
||||
"@type" "EntryPoint"
|
||||
"urlTemplate" (printf "%s?q={search_term_string}" .Site.Home.Permalink)
|
||||
)
|
||||
"query-input" "required name=search_term_string"
|
||||
)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $software := dict
|
||||
"@type" "SoftwareApplication"
|
||||
@@ -64,6 +88,19 @@
|
||||
{{- $pageType = "TechArticle" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $itemListItems := slice -}}
|
||||
{{- $itemListID := printf "%s#itemlist" .Permalink -}}
|
||||
{{- if .IsSection -}}
|
||||
{{- range $index, $child := first 20 .Pages.ByWeight -}}
|
||||
{{- $itemListItems = $itemListItems | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add $index 1)
|
||||
"name" $child.Title
|
||||
"url" $child.Permalink
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $page := dict
|
||||
"@type" $pageType
|
||||
"@id" $pageID
|
||||
@@ -87,16 +124,77 @@
|
||||
"author" (dict "@id" $orgID)
|
||||
"mainEntityOfPage" (dict "@type" "WebPage" "@id" $pageID)
|
||||
) -}}
|
||||
{{- with .PublishDate -}}
|
||||
{{- $page = merge $page (dict "datePublished" (.Format $iso8601)) -}}
|
||||
{{- end -}}
|
||||
{{- with .Lastmod -}}
|
||||
{{- $page = merge $page (dict "dateModified" (.Format $iso8601)) -}}
|
||||
{{- end -}}
|
||||
{{- with .PublishDate -}}
|
||||
{{- $page = merge $page (dict "datePublished" (.Format $iso8601)) -}}
|
||||
{{- end -}}
|
||||
{{- with .Lastmod -}}
|
||||
{{- $page = merge $page (dict "dateModified" (.Format $iso8601)) -}}
|
||||
{{- end -}}
|
||||
{{- if and .IsSection (gt (len $itemListItems) 0) -}}
|
||||
{{- $page = merge $page (dict "mainEntity" (dict "@id" $itemListID)) -}}
|
||||
{{- end -}}
|
||||
{{- $pageParts := slice -}}
|
||||
{{- if ge (len $tocItems) 2 -}}
|
||||
{{- $pageParts = $pageParts | append (dict "@id" $tocID) -}}
|
||||
{{- end -}}
|
||||
{{- if gt (len $videoItems) 0 -}}
|
||||
{{- range $videoItems -}}
|
||||
{{- $pageParts = $pageParts | append (dict "@id" (index . "@id")) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if gt (len $pageParts) 0 -}}
|
||||
{{- $page = merge $page (dict "hasPart" $pageParts) -}}
|
||||
{{- end -}}
|
||||
{{- with $breadcrumb -}}
|
||||
{{- $page = merge $page (dict "breadcrumb" (dict "@id" (index . "@id"))) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $graph := slice $org $website $page -}}
|
||||
{{- with $breadcrumb -}}
|
||||
{{- $graph = $graph | append . -}}
|
||||
{{- end -}}
|
||||
{{- if and .IsSection (gt (len $itemListItems) 0) -}}
|
||||
{{- $graph = $graph | append (dict
|
||||
"@type" "ItemList"
|
||||
"@id" $itemListID
|
||||
"url" .Permalink
|
||||
"numberOfItems" (len $itemListItems)
|
||||
"itemListOrder" "https://schema.org/ItemListOrderAscending"
|
||||
"itemListElement" $itemListItems
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- if ge (len $tocItems) 2 -}}
|
||||
{{- $graph = $graph | append (dict
|
||||
"@type" "ItemList"
|
||||
"@id" $tocID
|
||||
"name" ((T "onThisPage") | default "On this page")
|
||||
"url" .Permalink
|
||||
"numberOfItems" (len $tocItems)
|
||||
"itemListOrder" "https://schema.org/ItemListOrderAscending"
|
||||
"itemListElement" $tocItems
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- if gt (len $videoItems) 0 -}}
|
||||
{{- $graph = $graph | append $videoItems -}}
|
||||
{{- end -}}
|
||||
{{- if ge (len $faqItems) 2 -}}
|
||||
{{- $faq := dict
|
||||
"@type" "FAQPage"
|
||||
"@id" $faqID
|
||||
"url" .Permalink
|
||||
"inLanguage" .Site.Language.Lang
|
||||
"isPartOf" (dict "@id" $websiteID)
|
||||
"mainEntity" $faqItems
|
||||
-}}
|
||||
{{- $graph = $graph | append $faq -}}
|
||||
{{- end -}}
|
||||
{{- if gt (len $howToItems) 0 -}}
|
||||
{{- $graph = $graph | append $howToItems -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $schema := dict
|
||||
"@context" "https://schema.org"
|
||||
"@graph" (slice $org $website $page)
|
||||
"@graph" $graph
|
||||
-}}
|
||||
<script type="application/ld+json">{{ $schema | jsonify | safeJS }}</script>
|
||||
|
||||
26
layouts/partials/utils/breadcrumb-schema-object.html
Normal file
26
layouts/partials/utils/breadcrumb-schema-object.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{- $breadcrumb := false -}}
|
||||
{{- $items := slice -}}
|
||||
{{- if not .Params.disableBreadcrumb -}}
|
||||
{{- range $index, $ancestor := .Ancestors.Reverse -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add $index 1)
|
||||
"name" $ancestor.Title
|
||||
"item" $ancestor.Permalink
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add (len $items) 1)
|
||||
"name" .Title
|
||||
"item" .Permalink
|
||||
) -}}
|
||||
{{- if gt (len $items) 1 -}}
|
||||
{{- $breadcrumb = dict
|
||||
"@type" "BreadcrumbList"
|
||||
"@id" (printf "%s#breadcrumb" .Permalink)
|
||||
"itemListElement" $items
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $breadcrumb -}}
|
||||
5
layouts/partials/utils/clean-structured-label.html
Normal file
5
layouts/partials/utils/clean-structured-label.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{- $label := . | default "" -}}
|
||||
{{- $label = $label | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- $label = replaceRE `^[0-9]+(?:\s*[.,::、))-]\s*|\s+)` "" $label -}}
|
||||
{{- $label = replaceRE `^[A-Za-z](?:\s*[.)]\s*|\s+)` "" $label -}}
|
||||
{{- return $label -}}
|
||||
32
layouts/partials/utils/faq-schema-items.html
Normal file
32
layouts/partials/utils/faq-schema-items.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := .RawContent | default "" -}}
|
||||
{{- if $raw -}}
|
||||
{{- $sections := after 1 (split (printf "\n%s" $raw) "\n## ") -}}
|
||||
{{- range $sections -}}
|
||||
{{- if lt (len $items) 8 -}}
|
||||
{{- $section := printf "## %s" . -}}
|
||||
{{- $lines := split $section "\n" -}}
|
||||
{{- $question := replaceRE `^##\s+` "" (index $lines 0) | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if and $question (or (hasSuffix $question "?") (hasSuffix $question "?")) -}}
|
||||
{{- $answerRaw := delimit (after 1 $lines) "\n" -}}
|
||||
{{- $answerRaw = replaceRE "(?ms)```.*?```" " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^!\[[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^\{\{%[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^\{\{<[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^-{3,}$` " " $answerRaw -}}
|
||||
{{- $answer := $answerRaw | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if gt (len $answer) 40 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "Question"
|
||||
"name" $question
|
||||
"acceptedAnswer" (dict
|
||||
"@type" "Answer"
|
||||
"text" (truncate 320 $answer)
|
||||
)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
46
layouts/partials/utils/howto-schema-items.html
Normal file
46
layouts/partials/utils/howto-schema-items.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if and $raw (not (in $page.RelPermalink "/faq/")) (not (in $page.RelPermalink "/strategy/")) -}}
|
||||
{{- $sections := after 1 (split (printf "\n%s" $raw) "\n## ") -}}
|
||||
{{- range $i, $sectionText := $sections -}}
|
||||
{{- if lt (len $items) 3 -}}
|
||||
{{- $section := printf "## %s" $sectionText -}}
|
||||
{{- $lines := split $section "\n" -}}
|
||||
{{- $name := replaceRE `^##\s+` "" (index $lines 0) | partial "utils/clean-structured-label.html" -}}
|
||||
{{- if and $name (not (or (hasSuffix $name "?") (hasSuffix $name "?") (in $name ","))) -}}
|
||||
{{- $body := delimit (after 1 $lines) "\n" -}}
|
||||
{{- $body = replaceRE "(?ms)```.*?```" " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^!\[[^\n]*$` " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^\{\{%[^\n]*$` " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^\{\{<[^\n]*$` " " $body -}}
|
||||
{{- $stepsRaw := findRE `(?m)^\d+\.\s+.+$` $body -}}
|
||||
{{- if ge (len $stepsRaw) 3 -}}
|
||||
{{- $steps := slice -}}
|
||||
{{- range $stepIndex, $stepRaw := first 8 $stepsRaw -}}
|
||||
{{- $stepText := replaceRE `^\d+\.\s+` "" $stepRaw | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if gt (len $stepText) 10 -}}
|
||||
{{- $steps = $steps | append (dict
|
||||
"@type" "HowToStep"
|
||||
"position" (add $stepIndex 1)
|
||||
"name" (truncate 120 $stepText)
|
||||
"text" $stepText
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if ge (len $steps) 3 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "HowTo"
|
||||
"@id" (printf "%s#howto-%d" $page.Permalink (add (len $items) 1))
|
||||
"name" $name
|
||||
"url" $page.Permalink
|
||||
"inLanguage" $page.Site.Language.Lang
|
||||
"step" $steps
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
21
layouts/partials/utils/toc-schema-items.html
Normal file
21
layouts/partials/utils/toc-schema-items.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if and (or $page.IsPage $page.IsSection) $raw -}}
|
||||
{{- $raw = replaceRE "(?ms)```.*?```" "\n" $raw -}}
|
||||
{{- range findRE `(?m)^#{2,3}\s+.+$` $raw -}}
|
||||
{{- if lt (len $items) 12 -}}
|
||||
{{- $rawLine := replaceRE `^#{2,3}\s+` "" . | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- $line := partial "utils/clean-structured-label.html" $rawLine -}}
|
||||
{{- if gt (len $line) 2 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add (len $items) 1)
|
||||
"name" $line
|
||||
"url" (printf "%s#%s" $page.Permalink ($rawLine | anchorize))
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
46
layouts/partials/utils/video-schema-items.html
Normal file
46
layouts/partials/utils/video-schema-items.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $seenIDs := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if $raw -}}
|
||||
{{- $raw = replaceRE `\r?\n\]\(` `](` $raw -}}
|
||||
{{- $currentHeading := $page.Title -}}
|
||||
{{- range split $raw "\n" -}}
|
||||
{{- $line := . -}}
|
||||
{{- $headingMatch := findRESubmatch `^#{2,3}\s+(.+)$` $line -}}
|
||||
{{- with $headingMatch -}}
|
||||
{{- $currentHeading = index (index . 0) 1 | partial "utils/clean-structured-label.html" -}}
|
||||
{{- end -}}
|
||||
{{- $matches := findRESubmatch `\[(.*?)\]\((https?://(?:www\.)?(?:youtube\.com/watch\?v=[^)#\s]+|youtu\.be/[^)#\s]+)[^)]*)\)` $line -}}
|
||||
{{- range $matches -}}
|
||||
{{- if lt (len $items) 8 -}}
|
||||
{{- $title := index . 1 | partial "utils/clean-structured-label.html" -}}
|
||||
{{- $url := index . 2 | chomp -}}
|
||||
{{- $videoID := "" -}}
|
||||
{{- if in $url "youtu.be/" -}}
|
||||
{{- $videoID = replaceRE `^.*youtu\.be/([^?&#/]+).*$` `$1` $url -}}
|
||||
{{- else -}}
|
||||
{{- $videoID = replaceRE `^.*[?&]v=([^?&#/]+).*$` `$1` $url -}}
|
||||
{{- end -}}
|
||||
{{- if or (not $title) (eq $title $url) (hasPrefix $title "http://") (hasPrefix $title "https://") -}}
|
||||
{{- $title = $currentHeading | default $page.Title -}}
|
||||
{{- end -}}
|
||||
{{- if and $title $videoID (not (in $seenIDs $videoID)) -}}
|
||||
{{- $seenIDs = $seenIDs | append $videoID -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "VideoObject"
|
||||
"@id" (printf "%s#video-%s" $page.Permalink $videoID)
|
||||
"name" $title
|
||||
"url" $url
|
||||
"embedUrl" (printf "https://www.youtube.com/embed/%s" $videoID)
|
||||
"thumbnailUrl" (printf "https://i.ytimg.com/vi/%s/hqdefault.jpg" $videoID)
|
||||
"inLanguage" $page.Site.Language.Lang
|
||||
"isPartOf" (dict "@id" (printf "%s#webpage" $page.Permalink))
|
||||
"publisher" (dict "@id" "https://rustdesk.com/#organization")
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
Reference in New Issue
Block a user