prestaconcept/PrestaSitemapBundle

Allow to add custom URLs to sitemap index without populating section

norkunas opened this issue · 12 comments

Description
We have a nextjs app for landing pages in front of our internal app, previously we managed sitemaps
in the internal app with this bundle, but now that nextjs app is multilingual, it exposes it's sitemap and
then we proxy it. But we have to fake add at least one URL so it is added to the sitemap root.

Example
Not sure what's the best option here, maybe new event like SitemapRootCreatedEvent
and then in Presta\SitemapBundle\Service\AbstractGenerator::getRoot dispatch it?

I'm sorry, but I don't understand neither the issue you are facing nor the solution you are pointing
Is there any chance you can try to reformulate?

All right, in simple words: how to add something to sitemap index without using SitemapPopulateEvent ?

In the context of? generating the sitemap? dumping the sitemap?

dumping :)

I don't understand why you cannot rely on SitemapPopulateEvent, but here's my 2 cent:
Add a listener to console.command, with a dependency on \Presta\SitemapBundle\Service\DumperInterface and call \Presta\SitemapBundle\Service\UrlContainerInterface::addUrl on it

I don't understand why you cannot rely on SitemapPopulateEvent

if it's possible to add a different sitemap link without adding an URL for that section, then I could if you'd share some example 🤔

OK, I think I understand better your need
You need a sitemap index file, pointing to sitemap (sections), but these sitemaps will not contain any url (the associated file will not even exist)

Am I correct ?

Yes something like that.
We use that event for most of our sitemaps, but our microservice has it's own sitemap, so I just need to add a pointer that it exists :)

I don't think it is a good idea to add to this bundle the ability to have empty sitemap sections
The system heavily rely on the presence of URLs to be generated

I suggest you find another solution for your sitemap index to be generated
Because you are not going to add any URL to this sitemap, I suggest you just generate the sitemap index using a twig template (or anything else)

So that means this bundle can't be friendly to any other sitemap generators? :) because the current workaround is to add random url to that section, so it is at least exposed through sitemap index

There is nothing to do with "being friendly", please stay nice

I don't say you are doing things wrong or something alike
But thing is the thing you ask is going against the DNA of the library
So, to me it is a no go

Okay, then will use current workaround, thanks for your time 🙏