瞭解如何透過為AEM Sites建立Sitemap來協助提升SEO。
AEM Sitemap透過使用支援絕對URL Sling對應. 這是透過在產生Sitemap (通常是AEM Publish服務)的AEM服務上建立對應節點來完成的。
Sling對應節點定義的範例 https://wknd.com
可定義於 /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
)。
定義 OSGi工廠設定 對於頻率(使用 cron運算式)在AEM中重新/產生並快取sitemap。
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"
}
允許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" }
確定 .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]