In a bipartite graph, every isometric path is a retract. I know this is true because I see it used in a few papers I am using for a project, but I can't find a solid proof.
I have tried some examples to try and figure out how to define my homomorphism but I am not seeing a way to generalize. I know I need some homomorphism into this path such that the restriction is the identity map on the path.
I tried mapping vertices of the bipartite graph to the vertices on the path that are closest distance but that failed because it assumed connectivity.
Any help would be great.
 A: Indeed the idea you propose doesn't work, but connectivity is the least of your problems. Suppose that $G = (V,E)$ is our bipartite graph and that the vertex set $H \subseteq V$ defines an isometric path. A vertex $v \in V \setminus H$ in the same component as $H$ need not have a unique closest vertex on the path, so the map is not well defined. Furthermore, even if $v \in V \setminus H$ has a unique neighbour $w$ on $H$, then mapping $v$ to $w$ is a bad idea, for this can never be a homomorphism (there is an edge $vw$ in $G$, but there is no edge from $w$ to $w$).
This brings us to a fundamental (and somewhat confusing) property of graph homomorphisms (assuming we're only considering loopless graphs): different endpoints of an edge cannot be sent to the same vertex! In other words, the preimage of every vertex must be an independent set. This gives the following interesting characterisation of the chromatic number of a graph: it is the minimum number $\ell \in \mathbb{N}$ so that there exists a homomorphism $G \to K_\ell$.
In particular, any bipartite graph $G = (V,E)$ has a homomorphism to $K_2$. If we let $A,B \subseteq V$ denote the colour classes of $G$, then the vertices in $A$ are sent to one vertex and the vertices in $B$ to the other.

Thus, we only really have to worry about the component containing $H$; the other components can be mapped to an arbitrary edge in $H$. We may therefore assume without loss of generality that $G$ is connected. Let $v_0 \in H$ be one of the endpoints of our isometric path, and let $k := \epsilon(v_0)$ denote its eccentricity (that is, the maximum distance from $v_0$ to any other vertex). Let $P_{k+1}$ denote the path graph on $k + 1$ vertices $x_0,\ldots,x_k$. We define a homomorphism $f : G \to P_{k+1}$ in the following way:
$$ f(w) = x_{d(v_0,w)}. $$
In other words: $v_0$ is sent to $x_0$, all neighbours of $v_0$ are sent to $x_1$, the neighbours of the neighbours of $v_0$ are sent to $x_2$, and so on. It is not too hard to show that this is a homomorphism; I'll leave this as an exercise. (Suppose that $u,w\in V$ are adjacent, then it is easy to see that $u$ and $w$ are either sent to neighbouring vertices or to the same vertex. To rule out the latter, use that $G$ is bipartite.)
Now let $\ell := |H|$ denote the number of vertices in our isometric path. Note that we have $\ell \leq k + 1$. We choose some homomorphism $h : P_{k+1} \to P_\ell$ such that the first $\ell$ vertices of $P_{k+1}$ are mapped to the first $\ell$ vertices of $P_\ell$. For instance, $g$ could be the following zigzag homomorphism (illustrated here for the case $k = 27$ and $\ell = 7$):

Finally, let $h : P_\ell \to H$ be the homomorphism that identifies $P_\ell$ with our original path $H$, in such a way that the first vertex of $P_\ell$ is sent to $v_0$. Now we consider the composition
$$ G \stackrel{f}{\longrightarrow} P_{k+1} \stackrel{g}{\longrightarrow} P_\ell \stackrel{h}{\longrightarrow} H. $$
This gives a homomorphism $\varphi : G \to H$. It is not so hard to see that $\varphi$ is a retraction, so that $H$ a retract.

Finally, as a side note, I would like to remark that a path that is not isometric cannot be a retract: now there is some shorter path $H'$ between the endpoints of $H$, but there does not exist a homomorphism $H' \to H$ that preserves both endpoints. Furthermore, if $G$ is not bipartite, then no path in $G$ can be a retract; otherwise we would have a 2-colouring of $G$ given by the composition $G \longrightarrow P_m \longrightarrow K_2$ of graph homomorphisms. (In simpler terms: a 2-colouring of the path can be lifted back along the retraction to give a 2-colouring of $G$.) Hence we have proven the following characterisation:

Proposition. Let $G$ be a graph and let $P$ be a path in $G$ with at least $2$ vertices. Then $P$ is a retract if and only if $G$ is bipartite and $P$ is isometric.

(A single vertex is only a retract if $G$ has no edges.)
