亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

網址重復。

網址重復。

Go
Qyouu 2021-04-16 18:02:16
我想使用架構輸出我的面包屑,但是@id重復兩次URL或有時重復更多?因此,如果我訪問該about頁面,則會看到:"@id":"http://localhost:1313/about/http://localhost:1313/about/",當我使用分頁時,它會重復更多URL:"@id":"http://localhost:1313/blog/http://localhost:1313/blog//http://localhost:1313/blog/http://localhost:1313/blog//http://localhost:1313/blog/http://localhost:1313/blog/",我正在使用的代碼: 摘自:https : //gohugohq.com/partials/breadcrumb-partial-with-structured-data-in-hugo/{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}{{ $.Scratch.Add "path" .Site.BaseURL }}{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) }}{{ range $index, $element := split $url "/" }}{{ $.Scratch.Add "path" $element }}{{ $.Scratch.Add "path" "/" }}{{ if ne $element "" }}{{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) }}{{ end }}{{ end }}<script type="application/ld+json">{  "@context": "http://schema.org",  "@type": "BreadcrumbList",  "itemListElement": [{{ range $.Scratch.Get "breadcrumb" }}{{ if ne .position 1 }},{{ end }}{        "@type": "ListItem",        "position": {{ .position }},        "item": {          "@id": "{{ .url }}",          "name": "{{ .name }}"        }    }{{ end }}]}</script>
查看完整描述

2 回答

?
一只甜甜圈

TA貢獻1836條經驗 獲得超5個贊

所以我不確定您的列表頁面模板是什么樣的,但是例如在我的

{{ partial "header.html" . }}

應該什么時候

{{ partial "header" . }}

這刪除了重復的URL。我在標題部分中都渲染了所有相同的代碼。


查看完整回答
反對 回復 2021-04-19
?
神不在的星期二

TA貢獻1963條經驗 獲得超6個贊

網址重復的原因有兩個

  1. 雨果熱重裝的已知錯誤。但是最終的生產版本將沒有它。因此,運行hugo并檢查公用文件夾。

  2. 如果公共文件夾上的問題仍然存在,請檢查您正在執行多少次局部操作{{ $.Scratch.Add "path" .Site.BaseURL }}。添加一次后,便可以從頭開始在同一頁面的所有部分上獲得相同的數據。

我有關于雨果的面包屑部分的博客帖子,帶有json-ld

我重復使用相同的草稿在頁面上顯示面包屑。

只需添加搜索引擎的面包屑即可。還向用戶顯示它們。


查看完整回答
反對 回復 2021-04-19
  • 2 回答
  • 0 關注
  • 371 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號