Question: Our Environment : SDL Tridion 2013 SP1

We are trying to automate sitemap during every page publishing/unpublishing. The requirement is to create two sitemap files (audiositemap.xml/videositemap.xml). While creating content pages, author would choose whether the page type is audio or video in page metadata.

During publishing/unpublishing, if the page type is audio, url needs to be added in audiositemap.xml file. If it is video type page, it should be added in videositemap.xml.

Can anyone suggest if it can be done through event handler, deployer extension or db customization? Or any other better way.

Answer: 
Well, this wouldn't be Tridion if there weren't 15 ways of doing it. My preferred approach for this - given that you already have the sitemap logic built into CM Templates - would be to use a [Custom Resolver](http://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v1/GUID-F792AB1A-060A-4757-802D-3A2DB18F022D).

While functionally it can achieve the same as an Event, the reason why I would choose this approach is that it would allow you to add the navigation page in question to the *same* publish transaction, resulting in slightly better performance than creating one additional transaction, and - because it's in the same transaction - if for any reason the other page fails to publish, so does the navigation page.
Welcome the tridion community.

Coming to your question about generating site map using event handler is not good idea, because when you publish in bulk, there will be performance and concurrency issues which are very difficult to handle and if you are able to handle them that will be at the cost of increased publishing time.

The better approach to implement sitemap is through storage extension. You can refer to the link: [storage extension](https://community.sdl.com/products-solutions/solutions/customer_experience_cloud/digital-experience/tridion/tridion-developer/b/weblog/archive/2011/11/05/extending-content-delivery-storage-in-sdl-tridion-2011-part-3?pi864299333=6)