  In this paper we propose formulas for the distance between vertices of a
generalized Sierpi\'{n}ski graph $S(G,t)$ in terms of the distance between
vertices of the base graph $G$. In particular, we deduce a recursive formula
for the distance between an arbitrary vertex and an extreme vertex of $S(G,t)$,
and we obtain a recursive formula for the distance between two arbitrary
vertices of $S(G,t)$ when the base graph is triangle-free. From these recursive
formulas, we provide algorithms to compute the distance between vertices of
$S(G,t)$. In addition, we give an explicit formula for the diameter and radius
of $S(G,t)$ when the base graph is a tree.
