Cleanup permalink generation

Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.
I would add a blank line between the `let()` and the `include_examples` line like you've done elsewhere (and is normally our style).