The 18-year-old former Balcarras School pupil made his first start of the season against Newport County last Sunday, playing just off front man Terry Gornell.
Academy graduate Williams had made two previous substitute appearances under boss Paul Buckle, having started three matches last season after breaking into the first team picture.
He becomes the fourth youngster to commit his future to Buckle's Robins, following Omari Sterling-James, Zack Kotwica and Joe Hanks.