What was the relative distance of the artillery from the front lines during WW1? Were they close enough to get fire small arms or were they relatively far removed from combat?
They were generally placed beyond the reach of small arms and machine gun fire, but the actual distances could vary quite a bit.
Field guns like the French 75mm or the British 18-Pounder could throw a shell about 6 to 7 kilometers.
Larger siege artillery, like the British 9.2" howitzer could lob a shell twice this distance, while the 6" Mk XIX gun could, in theory, strike targets almost 19 kilometers away.
So these are the extreme ranges of the hardware, and you might put some of your guns at such a distance away from the enemy's front line.
However it's a bit more complicated than that. You don't just want to strike the enemy's front line trench, you also want to
Be able to target his second and third line trenches, and his lines of communication further to the rear, and target any troops massing for a counter attack in the enemy's rear areas.
To lay down a creeping barrage in support of your advancing infantry as shown in this barrage map for the battle of the Messines Ridge Road, part of Third Ypres, in 1917.
Conduct counter-battery fire to suppress or destroy the enemy's artillery.
None of the above can be done if you place all your guns as far back as possible, but obviously, if you move your own guns forward, they become increasingly vulnerable to enemy counter-battery and liable to be overrun if the enemy make any significant advance.
So I guess the TL;DR is that the distance varied but if your guns were within range of small arms fire from the enemy then something had gone horribly wrong.
Finally, if a picture paints a thousand words, have a look at this map which shows the placement of German artillery around the Hindenburg Line.