fixes saving permalinks when using joins and includes

Fixes #2385