hi tim, I'm also suffer from last section today, here's my cure:
I use your last
LI(null, A({"href" : "/"+pagename}, pagename));
but I keep <head > clean without adding
py:match="item.tag=='{http://www.w3.org/1999/xhtml}head'"
as tutorial, and remove the
<meta py:replace="item[:]"/>
Then all function works! (though I don't know why ....)
Fred

