Sitemaps

瞭解如何為AEM Sites建立Sitemap,以利提升SEO。

WARNING
此影片示範如何在網站地圖中使用相對URL。 Sitemap 應使用絕對URL。 請參閱組態以瞭解如何啟用絕對URL,因為下列影片並未說明此問題。

設定

絕對網站地圖URL absolute-sitemap-urls

AEM的Sitemap使用Sling對應支援絕對URL。 這是透過在產生Sitemap (通常是AEM Publish服務)的AEM服務上建立對應節點來完成。

https://wknd.com的Sling對應節點定義範例可在/etc/map/https下定義,如下所示:

路徑
屬性名稱
屬性型別
屬性值
/etc/map/https/wknd-site
jcr:primaryType
字串
nt:unstructured
/etc/map/https/wknd-site
sling:internalRedirect
字串
/content/wknd/(.*)
/etc/map/https/wknd-site
sling:match
字串
wknd.com/$1

以下熒幕擷圖說明類似設定,但適用於http://wknd.local (在http上執行的本機主機名稱對應)。

Sitemap絕對URL組態

Sitemap排程器OSGi設定

定義在AEM中重新/產生並快取Sitemap的頻率(使用cron運算式)的OSGi工廠設定

ui.config/src/main/jcr_content/apps/wknd/osgiconfig/config.publish

{
  "scheduler.name": "WKND Sitemaps",
  "scheduler.expression": "0 0 2 1/1 * ? *",
  "searchPath": "/content/wknd"
}

Dispatcher允許篩選器規則

允許Sitemap索引和Sitemap檔案的HTTP要求。

dispatcher/src/conf.dispatcher.d/filters/filters.any

...

# Allow AEM sitemaps
/0200 { /type "allow" /path "/content/*" /selectors '(sitemap-index|sitemap)' /extension "xml" }

Apache Webserver重寫規則

請確定.xml個Sitemap HTTP要求已路由到正確的基礎AEM頁面。 如果未使用URL縮短功能,或使用Sling對應來縮短URL,則不需要進行此設定。

dispatcher/src/conf.d/rewrites/rewrite.rules

...
RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg|.xml)$
RewriteRule ^/(.*)$ /content/${CONTENT_FOLDER_NAME}/$1 [PT,L]

資源

recommendation-more-help
bb44cebf-d964-4e3c-b64e-ce882243fe4d