Do rudder pedals slide or hinge? I am planning on making a pair of rudder pedals from scratch. I don't know whether they should be hinged, or slide forwards and backwards.

On real aircraft, how do they work? Does it vary from plane to plane?
I've never seen "sliding" rudder pedals in a light GA plane - though there may be such designs in transport aircraft, especially fly-by-wire planes.

If you're looking for simplicity for a homebuilt aircraft or simulator I'd go with hinged pedals pivoting at the floor similar to what you'll find on a Piper Cub (which can be made by welding tubes together into an I shape), or any number of similar floor-mounted designs:
 

(As shown in the first picture, toe brakes can be easily retrofitted onto such a design, and as shown in the second you can mount square pedals on them if you want to, though the round bar has some advantages.)