[opencms-dev] OpenCms 10.5/11: Change behaviour of SEO configuration file

Michael Emmerich m.emmerich at alkacon.com
Thu Feb 11 08:30:25 CET 2021


Kai,

you should extend the class CmsXmlSitemapGenerator.

In your implementation, the methods

public List<CmsXmlSitemapUrlBean> generateSitemapBeans() throws 
CmsException

protected String getInnerXmlForEntry(CmsXmlSitemapUrlBean entry)

protected String getXmlForEntry(CmsXmlSitemapUrlBean entry)

Are worth to look at.

I had a similar request like yours (but where many additonal things had 
to be doen, so I remove the "index.hmtl" in generateSitemapBeans:

public List<CmsXmlSitemapUrlBean> generateSitemapBeans() throws 
CmsException {

         // we have to correct the urls in the sitemap beans as it 
always returns the
         // urls to the index.html files and not the folders.

         List<CmsXmlSitemapUrlBean> list = super.generateSitemapBeans();

         List<CmsXmlSitemapUrlBean> correctedList = new 
ArrayList<CmsXmlSitemapUrlBean>();

        [...]

         for (CmsXmlSitemapUrlBean bean : list) {

        [...]

                 String onlineLink = bean.getUrl();
                 if (onlineLink.endsWith("index.html")) {
                     onlineLink = onlineLink.substring(0, 
onlineLink.length() - 10);
                 }
                 CmsXmlSitemapUrlBean newBean = new 
CmsXmlSitemapUrlBean(onlineLink, bean.getDateLastModified() == null ? -1 
: bean.getDateLastModified().getTime(),
                         bean.getChangeFrequency(), bean.getPriority());
  newBean.setDetailPageResource(bean.getDetailPageResource());
  newBean.setOriginalResource(bean.getOriginalResource());
                 correctedList.add(newBean);

         [...]

         }

     [..]

    return correctedList;

}

Hope this helps,

Michael



Am 10.02.21 um 16:55 schrieb Schliemann, Kai:
>
> Hi list members,
>
> anybody ever changed the output of the sitemap.xml file (file type seo 
> configuration file)?
>
> We would like the links to be generated without default-file (index.html).
>
> So instead of
>
> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9 
> <http://www.sitemaps.org/schemas/sitemap/0.9>">
>
> <url>
>
> <loc>http://localhost:8080/index.html</loc 
> <http://localhost:8080/index.html%3c/loc>>
>
> <lastmod>2021-02-10T10:34:45+01:00</lastmod>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/overview/index.html</loc 
> <http://localhost:8080/overview/index.html%3c/loc>>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/login/index.html</loc 
> <http://localhost:8080/login/index.html%3c/loc>>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/mercury-demo/index.html</loc 
> <http://localhost:8080/mercury-demo/index.html%3c/loc>>
>
> <lastmod>2021-02-10T10:34:39+01:00</lastmod>
>
> </url>
>
>>
> </urlset>
>
> We would like to have:
>
> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9 
> <http://www.sitemaps.org/schemas/sitemap/0.9>">
>
> <url>
>
> <loc>http://localhost:8080/</loc <http://localhost:8080/%3c/loc>>
>
> <lastmod>2021-02-10T10:34:45+01:00</lastmod>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/overview/</loc 
> <http://localhost:8080/overview/%3c/loc>>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/login/</loc 
> <http://localhost:8080/login/%3c/loc>>
>
> </url>
>
> <url>
>
> <loc>http://localhost:8080/mercury-demo/</loc 
> <http://localhost:8080/mercury-demo/%3c/loc>>
>
> <lastmod>2021-02-10T10:34:39+01:00</lastmod>
>
> </url>
>
>>
> </urlset>
>
> Where is this behaviour changed?
>
> Thanks in advance for your help.
>
> Best regards
>
> Kai
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> https://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
>
-- 
Michael Emmerich
  
-------------------

Alkacon Software GmbH & Co. KG - The OpenCms Experts
Michael Emmerich

Email: m.emmerich at alkacon.com

http://www.alkacon.com
http://www.opencms.org

Amtsgericht Köln, HRA 32185, USt-IdNr.: DE259882372
Vertreten durch: Alkacon Verwaltungs GmbH
Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 88218

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.opencms.org/pipermail/opencms-dev/attachments/20210211/197a7d4b/attachment.htm>


More information about the opencms-dev mailing list