站点地图

了解如何通过为AEM Sites创建站点地图来帮助提升SEO。

资源

配置

Sitemap调度程序OSGi配置

定义 OSGi工厂配置 (使用 cron表达式)站点地图会在AEM中重新生成和缓存。

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"
}

绝对站点地图URL

AEM Sitemap通过使用 Sling映射. 这是通过在AEM服务上创建映射节点以生成站点地图(通常为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)。

Sitemap绝对URL配置

调度程序允许过滤器规则

允许站点地图索引和站点地图文件的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 站点地图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]

在此页面上