CASCADE LOCKS, Ore. — He posted photos of himself on Facebook as he hiked hundreds of miles of the vast Pacific Crest Trail, masked in a bandanna to protect his lungs from the smoke of the fires that had closed down parts of it. She told him about the inner workings of NASA, where she was a college intern in Alabama.

As the West burned a year ago, Mark Beebe, the hiker, and Tara Prevo, the intern who was then stationed more than 2,000 miles away, began getting to know one another first through a connection on Facebook, then through texts, phone calls and trailside video. He told her of his job delivering pizzas in Portland, Ore., to make ends meet, leaving long days to rove the woods. She told him about her time of homelessness, living for a monthslong stretch out of a pickup truck.

But it was the fires, they said — and the lure of the Pacific Crest Trail, which Ms. Prevo was already dreaming of trying to hike herself — that forged their relationship.