Grails 中的 XML 站点地图
我正在尝试找出生成 XML 站点地图的最佳方法(如下所述: http://www.sitemaps.org /)用于 Grails 应用程序。我不知道任何现有的插件可以做到这一点,所以我可能会构建一个。但是,我想首先获得社区的意见。除了支持标准控制器/操作之外,我认为支持内容驱动的应用程序以及可能基于标题属性生成 URL 的应用程序会很好。
你们会怎么做呢?您会考虑什么以及如何实施?
谢谢!
I am trying to figure out the best way to generate an XML sitemap (as described here: http://www.sitemaps.org/) for a Grails application. I am not aware of any existing plugins that do this so I might build one. However, I wanted to get the community's input first. Aside from supporting standard controllers/actions, I am thinking it would be nice to support content driven apps as well where the URL might be generated based on a title property for example.
How would you guys go about this? What would you consider and how would you implement it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
站点地图对于每个应用程序来说都是非常特定的,因此我不确定是否有足够的通用代码可以提取到插件中。
以下是我们为 http://www.shareyourlove.com 生成站点地图的方法。正如您所看到的,由于 Groovy/Grails 良好的 XML 语法
URL 映射,它非常简单且干燥
Sitemaps are pretty specific to each app so I'm not sure if there is enough common code to pull out to a plugin.
Here is how we generate our sitemap for http://www.shareyourlove.com. As you can see it's pretty minimal and DRY due to Groovy/Grails's nice XML syntax
URL Mappings
我正在使用 UrlMappings.groovy 在 Grails 上制作站点地图,并且这种做法不需要控制器。我将下一个代码放入 UrlMappings 中:
并使用 xml 编码将站点地图创建为 gsp,例如 sitemap.gsp:
I was doing a sitemap on Grails with a UrlMappings.groovy and does not need a controller for this practice. I putted the next code in the UrlMappings:
And I create my sitemap as gsp with xml encoding, example of sitemap.gsp: