Yes, a dirty pillow can contribute to a stye. Pillowcases accumulate bacteria, oil, and debris, which can transfer to your eyes while you sleep. This can lead to bacterial infection of the oil glands or hair follicles on the eyelid, causing a stye. Regularly washing pillowcases helps reduce this risk.