Fix {category} and {tag} placeholders when called from subdirs

{category} placeholder was failing for me when called from a page in a subdir. This change fixes it by applying the to {category} and {tag} the same operations applied to {filename}.