寄り道 and 経由: a side visit and a point on the route
Compare a bookstore visit on the way home with a train traveling via a mountain station, distinguishing a side visit from route information.
Stopping at a bookstore on the way home
寄り道 (よりみち) is a side visit during a journey. 「帰宅途中に本屋へ寄り道した。」 says that the speaker stopped at a bookstore on the way home.
Going home is the main journey, and the bookstore is a place visited along the way. The visit took place, but the sentence says neither that books were bought nor whether the visit was planned.
The mountain station on the train's route
経由 (けいゆ) identifies a point through which a route passes. 「この列車は山の駅を経由して海辺へ向かう。」 says that this train heads to the coast via a mountain station.
山の駅 is a point on the route, and 海辺 is where the train is heading. The sentence describes the route without reporting that the train has already reached the coast.
A side visit and information about the route
The 寄り道 example describes a bookstore visit during the journey home. The 経由 example gives a point on the train's route.
Whether something was planned does not by itself separate the words. Compare the side visit with the route point here, keeping the focus on those roles rather than stops or transfers.
What information does 山の駅 provide in the train example?
Show the answer and why
It is a point the route passes through on the way to the coast. Its role differs from the bookstore visited during the journey home with 寄り道.

