What a difference two years makes.

Singer-songwriter Josh Ritter describes his most recent album, 2015’s “Sermon on the Rocks,” as loose, fun and wild. It’s a huge departure from 2013’s “The Beast in Its Tracks,” which focused on his divorce from fellow musician Dawn Landes.

Then again, Ritter has always been able to write in a wide variety of styles, from the religion-influenced story-songs on his new album to his 2011 novel about a World War I veteran, “Bright’s Passage,” to a collection of cowboy songs he is currently working on with the Grateful Dead’s Bob Weir.

amNewYork spoke with Ritter.

Where did the title “Sermon on the Rocks” come from?

“Sermon on the Rocks” was an idea I had in response to all the imagery of the Sermon on the Mount that’s on the record. I didn’t realize I was writing so much about it, but I was. I thought of “Sermon on the Rocks” as a more earthbound exploration of what the Sermon on the Mount was about. I also thought it was a funny title.

If you were to give a sermon what would it be about?

I don’t like sermons that much. That’s one of things about records that’s a fine line. You want to write about the world and explore it, but you don’t want to educate.

Where do you get the ideas for the characters in your songs?

Those characters just kind of come to me. I don’t know where they come from. A song like “Henrietta, Indiana,” came about because I liked the phrase “Henrietta, Indiana.” Suddenly there’s this 20-year-old girl who’s married with a story about her father and her brother. It just jumped out. They always jump out. Sometimes I think I can invent one, but I can’t. They just have to happen.

How did the collaboration with Bob Weir come about?

Josh Kaplan in my band has played with Bob for a while. Bob was telling him about wanting to make a record of songs like he heard when he was working as a ranch hand in Wyoming. Josh told me that, and I immediately begged to be able to write a song and see if it was something Bob liked. It was and that’s how we started working together.

How did writing a book change you as a songwriter?

There’s so much about writing a book that’s like writing a song. You’re still putting one perfect word after another. You just know when you’re getting it right, but it takes a lot of time and a lot of work. Both songwriting and writing a novel are like that. But I can write a song and if I learn it, I can play it that night and get applause. A novelist can’t do that. They have to work day in and day out without being able to show anything for so long. I can get instant gratification.