recursively find slug root

Also, when index_sparse is set to true, when the slug is an empty string we don't set it.