The shank often has its origins at the top of the swing. Specifically, in the transition between backswing and downswing.
Golfers who shank often thrust the arms outward to start the downswing, flinging the club across the target line and producing a severe outside-to-in clubhead path which sends the hosel into the ball. Sometimes this happens when the player starts down with the shoulders, rather than the lower body.
It’s important to pull the club down on the same path it took going up, or slightly inside/under the backswing route. This keeps the arms and hands close to the body and prevents a shank.
You can work on this transition without a ball before proceeding to hitting shots. Simply set up in your normal position and swing to the top, then drop the arms into a flatter (more horizontal) position on the downswing rather than casting them outward. You should feel as though the arms are somewhat behind your body from here.
Once you’ve tried this several times, hit a few shots with the same motion. Focus on hitting the ball off the toe, which will keep the arms and club on the correct inside path.
Be careful not to overdo this inside move as a swing that’s too flat can also lead to shanks.