How do ants follow each other?
The chemical we are talking about here is called pheromone, trail pheromone to be specific.


  A pheromone is a secreted or excreted chemical factor that triggers a social response in members of the same species. Pheromones are chemicals capable of acting outside the body of the secreting individual to impact the behavior of the receiving individuals.1


Pheromones are of mainly 9 types (13 exactly, but 4 not so common) which are:


Aggregation pheromones
Alarm pheromones
Epideictic pheromones
Releaser pheromones
Signal pheromones
Primer pheromones
Territorial pheromones
Trail pheromones
Sex pheromones
Nasonov pheromones
Royal pheromones
Calming pheromones
Necromones2


Ants, and many other animals, use trail pheromones to mark their trail as a guide for others in their gang. Other ants, catching the signal of trail pheromone, follow the way it goes and reach their gang leader. Trail pheromones are volatile compounds, so it is not very likely that you would see ants following the exactly same path tomorrow or a week later. All ants release trail pheromones, so as long as ants are going through that path, the trail signal will keep getting stronger and will also tell lost ants "Hey, bro! We are going this way. Don't you want to join us?" See, for example, here3:



In the beginning, different ants follow different paths, but as soon as an ant finds the shortest path, all ants join it on that path, due to which pheromones on other paths evaporates and finally, they all walk in straight line.

Of course, trail pheromones are very useful for organisms who have lost their way home, but you know, other organisms, like their predators, are not just sitting and watching them. Some predators can also catch pheromones and find out where the whole team is going, to attack them all at once. Such chemicals are known as kairomones. See this4:


  A kairomone is a semiochemical, emitted by an organism, which mediates interspecific interactions in a way that benefits an individual of another species which receives it, and harms the emitter.


Semiochemical is just a type of pheromone which a species X releases, but a species Y can also respond to its presence. Its just like when you walk on road and say "Whoa! Seems like a pizza delivery van just passed by" (obviously, smell of pizza is not by a pheromone ;)

The trail pheromones released by army ants can also be detected by a blind snake or a forest beetle, leading it right inside their nest. Obviously, all semiochemicals are not bad. Chemicals like synomones (helping both species) and allomones (just the opposite of kairomones) are also present5, but they are beyond this question's scope.

References:


 Medical Definition of Pheromone
Types of Pheromones - Wikipedia
Life in Wireframe - Ant Algoithms
Kairomones - Wikipedia
These Pheromones Get The Animals That Secrete Them Killed