The Catechism does give prayer and devotion a part in the forgiveness of everyday faults: "every sincere act of worship or devotion revives the spirit of conversion and repentance within us and contributes to the forgiveness of our sins" (CCC 1437). It teaches that confession of venial sins is not strictly necessary, though strongly recommended (CCC 1458), and that perfect contrition, sorrow that arises from love of God above all else, obtains forgiveness of mortal sins if it includes the firm resolution to go to sacramental confession as soon as possible (CCC 1452). None of this makes the journey a substitute for the sacrament.
The confusion usually comes from indulgences. An indulgence attached to a pilgrimage or shrine is not the forgiveness of sin. The Catechism defines it as "a remission before God of the temporal punishment due to sins whose guilt has already been forgiven" (CCC 1471), and sacramental Confession is one of its conditions. The medieval pardons were framed the same way: Celestine V's grant at L'Aquila in 1294 was for those "sincerely repentant and confessed."
A pilgrimage made as penance has its place after forgiveness. "Absolution takes away sin, but it does not remedy all the disorders sin has caused" (CCC 1459), and the journey is one way a forgiven person responds. So the order matters: go to Confession first, or on the way, and then walk. Where you have wronged someone, making what amends you can comes before any journey.
Good to know: in the Middle Ages confessors and Church courts imposed pilgrimages for grave sins; today a penitential pilgrimage is a free choice, and you may wish to tell a priest what you intend. It need not be far or severe. St. Paul VI rejected penance that is "purely external," and a walk to a nearby shrine with prayer, simple food and alms is a true penitential pilgrimage.
Plan a pilgrimage