prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
347 stars 100 forks source link

sitemap index loc urls are generated without dump_directory parameter in url #268

Closed sabat24 closed 3 years ago

sabat24 commented 3 years ago
  1. Set dump_directory option for example to public_html/sitemap.
  2. Add some sections.
  3. sitemap.xml (index) will generate wrong url for each sitemap's section.
<loc>http://host/sitemap.sites.xml.gz</loc>

should be

<loc>http://host/sitemap/sitemap.sites.xml.gz</loc>

It's because Dumper uses following line to generate urlset

$url = $this->baseUrl . $this->sitemapFilePrefix . '.' . $name . '.xml';

So the only way to generate sitemap using CLI is to pass --base-url command with dump_directory variable. It's possible, but is very annoying beacuse you have to create a wrapper to generate that base-url params as it depends on .env configuration. Then you have to parse dump_directory path to remove public_html string. What's more basically it's not a base-url. It's just url to sitemap index.

In my opinion:

  1. dump_directory should only contain information about directory inside public_path or that should be another option for that. Option which can be set using config file (presta_sitemap).
  2. newUrlset should use that path to links other sections correctly.
  3. base url should be left as it is.
yann-eugone commented 3 years ago

This is a dump "subdir" related issue.

Looks likely #196 ?

sabat24 commented 3 years ago

Yes. It's duplicate. Somehow I missed it. If I use this bundle in next project I'll take a look closer and propose some solution there.

yann-eugone commented 3 years ago

I understand this may be annoying. But there is many context where a project is hosted.

For instance sometimes in http://acme.org/app app do not stand for "a subdir named app in my public dir" but "my entire project is accessible under /app".

Feel free to ask the people involved in the issue I mentioned (and myself) some help if you wish to contribute on this one.