I think, it should be without slash - `url_for('mainpage', name='presence_weekday.html')`