Hi Gael, Thanks for the reply.
Yes, I tried to configure the routes.py file but I couldn't change the URL. I just thought you might know how to do it, so I thought I'd ask. Actually, I have an other post running regarding the URL issue but it's not resolved yet. For example, if I want to have a robot.txt, I can't place that in the static folder because Google will look for it at http://www.mydomain.com/robot.txt so for that one I will have to figure out the URL issue. But for the sitemap.txt, you're right, I can place the sitemap in the static folder and link it in webmaster tools. I will do that. Thanks again. <http://www.mydomain.com/sitemap.txt> On Monday, December 14, 2015 at 4:51:15 PM UTC+8, Gael Princivalle wrote: > Hi Joe. > > I think you can resolve it by a pattern-based system routes.py > configuration. > > Personally I use a simple parameter-based system routes.py configuration > and I think it's difficult with it to obtain an URL like > http://www.mydomain.com/sitemap.txt . > So I put sitemaps.txt in a static folder static/sitemaps/sitemap.txt and > in Google webmaster (search console) I link the sitemap like that: > http://www.mydomain.com/static/sitemaps/sitemap.txt . > > If you find a solution for having http://www.mydomain.com/sitemap.txt please > share! > > Il giorno lunedì 14 dicembre 2015 00:28:45 UTC+1, Joe ha scritto: >> >> Hi Gael, >> >> That's great! Thanks very much. >> >> I wonder how I can then create a URL like >> http://www.mydomain.com/sitemap.txt instead of >> http://www.mydomain.com/init/default/sitemap.txt >> >> >> On Tuesday, October 20, 2015 at 5:30:03 PM UTC+8, Gael Princivalle wrote: >>> >>> Hello Joe. >>> >>> I use the Scheduler for that, for making every day a new updated sitemap. >>> I use txt sitemaps because I've saw that if an XML sitemap is too long >>> Google don't take care of it. In txt yes. >>> >>> Here is an example: >>> >>> def sitemap_txt_auto(): >>> import os >>> from gluon.myregex import regex_expose >>> # Statics URLs >>> exclusions = ['download', 'call', 'data', 'upload', 'browse', >>> 'delete'] >>> ctldir = os.path.join(request.folder,"controllers") >>> ctls=os.listdir(ctldir) >>> if 'appadmin.py' in ctls: ctls.remove('appadmin.py') >>> if 'manage.py' in ctls: ctls.remove('manage.py') >>> if 'default.py.1' in ctls: ctls.remove('default.py.1') >>> sitemap='http://www.yourdomain.com' >>> for ctl in ctls: >>> if ctl.endswith(".bak") == False: >>> filename = os.path.join(ctldir,ctl) >>> data = open(filename, 'r').read() >>> functions = regex_expose.findall(data) >>> for f in functions: >>> if not any(f in s for s in exclusions): # if function is >>> not in exclustions >>> sitemap += '\r\n' >>> sitemap += 'http://www.yourdomain.com/%s' % (f) >>> # Dynamic URLs >>> # News >>> news = db(db.news.on_line == True).select(db.news.ALL) >>> for item in news: >>> sitemap += '\r\n' >>> sitemap += 'http://www.yourdomain.com/news?id=%s' % (str(item.id >>> )) >>> # And other dynamic urls >>> file = open('%s/static/sitemaps/sitemap.txt' %request.folder, 'w') >>> file.write(sitemap) >>> file.close() >>> #FOr being sure that the sitemap have been made. >>> email_sent = mail.send( >>> to = '[email protected]', >>> subject = 'Sitemap youdomain', >>> message = 'The sitemap have been generated with >>> success.') >>> db.commit() >>> >>> from gluon.scheduler import Scheduler >>> Scheduler(db,dict(sitemap_txt_auto=sitemap_txt_auto)) >>> >>> Il giorno sabato 10 ottobre 2015 03:55:13 UTC+2, Joe ha scritto: >>>> >>>> What is the best way to implement a sitemap for a Web2py site? Is there >>>> a Web2py code to generate the sitemap or I should use a third party >>>> sitemap >>>> generator? If so, should I place the XML file in the static folder? >>>> I'd appreciate some advise on this. >>>> Thanks very much. >>>> Cheers, >>>> Joe >>>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

