Filter templates when calculating tags and categories

Prior to this change sphinx would consume the templates which include
templatized placeholders like "{{ tags }}", and these would show up in
the sidebar as literal tags and categories with zero counts.