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

Creation of sitemap.xml files in sub directory #306

Open rberneder opened 1 year ago

rberneder commented 1 year ago

There is the possibility to set the target directory where the files shall be dumped to. However the links between the generated section-xml-files don't respect that and try link the files from the web root.

Similar to the file prefix a sub-directory config would be great so the created links between each sitemap-file add this sub-directory in each path.

norkunas commented 1 year ago

I think if you are dumping to the sub-dir then you should configure routing prefix to be same in config/routes/presta_sitemap.yaml or where you import the routes

rberneder commented 1 year ago

If I understand correctly, you are proposing to expose the routes to the sitemap generation controller (which generates the sitemap on the fly). Due to the large amount of pages I prefer generating the sitemap.xml files regularly with a cron job:

bin/console presta:sitemaps:dump /var/www/public/sitemap/site-1 --base-url="https://www.site-1.com"

I think all it needs is to have an additional "relative-path-to-sitemap" parameter that is added to all sitemap-section-links.

yann-eugone commented 1 year ago

From an historical point of view, this bundle was created to serve sitemap on the fly But indeed, we moved to the dump command, because it was too much for an HTTP endpoint This is why there is some code aimed to be working on the HTTP side that still works on dump command So yes, I believe you could put some path in sitemap_file_prefix (ie site-1/sitemap) and it might work

But I think we better rethink this whole thing by making an inventory of all use cases we want to cover, and find a way to rewrite these code parts with new config structure

BriceFab commented 8 months ago

I've the same issue.

It's related with https://github.com/prestaconcept/PrestaSitemapBundle/issues/138

If you set --base-url, it will work. But it's not consistent