Rather than stay at a cheaper hotel nearby where there's nowhere to go in the evening stay down the road at Jaca, a really nice little town with lots of accommodation to choose from, sights to see, e.g. the tiny cathedral and the Vauban fortress, and good bars and restaurants. Then in the morning leave your clobber at the hotel and take the train up to Canfranc and back. The historic train is as cheap as chips and the line has fantastic views. Timetables change but last year I had loads of time to explore the station area, too much in fact so if I did it again I'd take the conventional train back which is also much more comfortable - and the historic train going back was rammed with folk starting their trip at Canfranc. I bought my seat
on line but saw people buying on the platform too.