Closed geodesic definition A geodesic is defined to be the curve in the manifold which has the shortest path/length between two points.
But when the curve is closed and the two points are the same then the curve length can vanish in a homotopy sense.
The shortest path is zero between a point and instelf. 
So I am confused about what is the definition of a "closed" geodesic.
 A: A geodesic is only the shortest possible paths between two points on it, IF the two points are sufficiently close to each other. The correct value of 'sufficiently close' depends on the manifold and is called the injectivity radius. It can be infinite (for example in $\mathbb{R}^n$) but if there are closed geodesics it is finite.
Edit in response to comment: On the standard sphere, the geodesics are the great circles. If you pick two points on the sphere (that are not directly opposite each other) there is a unique great circle that passes through both of them. There is a short way and a long way around the circle connecting the two points. The short way realizes the distance between them, the long one does not. You could define geodesics on the sphere by the property that for any two points on them at distance less than $\pi$ along the path, the path realizes the distance on the sphere.
A: For an intervall $I$ a smooth curve $\gamma: I\to M$ is  a geodesic iff it satisfies one of the following two equivalent conditions:


*

*$\gamma''(t)=0$

*$|\gamma'(t)|$ is constant and $\gamma$ is locally shortest, i.e. for all $t\in I$ there is a neighbourhood $J$ of $t$ such that for all $r,s\in J$ with $r<s$ $\gamma$ restricted to $[r,s]$ is the shortest path between $\gamma(r)$ and $\gamma(s)$
Here if $M$ is a submanifold of $\mathbb R^n$ then $\gamma''(t)$ is just the ordinary second derivative in $\mathbb R^n$ followed by the projection onto the tangent space $T_{\gamma(t)}M$. 
As already pointed out in the other answer an instructive example is the sphere $S^2$: The geodesics are the great circles parametrized with constant speed but if you start a geodesic at a point it will only minimize  lenght untill it reaches the opposite point.
