Hip-hop diss tracks regularly make headlines, but in the summer of 2017, it was a hip-hop apology track that jolted the music world into a gossip-driven frenzy that eclipsed any beef.

When Jay-Z quietly released his 13th studio album, “4:44,” on June 30, listeners quickly zoned into the lyrics of the title track and found the Brooklyn rapper begging his wife, Beyoncé Knowles, for forgiveness for his past philandering and boneheaded behavior. “I apologize, often womanize/Took me too long for this song/I don’t deserve you.”

Reports of Jay-Z’s infidelities were already widespread, referenced in Beyoncé’s 2016 album, “Lemonade,” and hinted at strongly in the infamous leaked footage of his sister-in-law Solange attacking him in a New York elevator in 2014. Even so, Jay-Z’s startlingly honest admission of wrongdoing caused a sensation across the world.

But the album was so much more than an elaborate attempt to get out of the doghouse. Now that the dust has settled, it’s revealed itself to be a high-water mark in modern hip-hop. “4:44” leads the pack at Sunday’s Grammy Awards with a remarkable eight nominations — including the Brooklynite’s first Album of the Year nod.

It’s a smart, thoughtful, mature and deeply personal album that captures his desire to leave a legacy for his three children, casts a harsh light of self-examination on his famously flashy past persona (established back in 1996 with the now legendary album “Reasonable Doubt”), and divulges that his mother is gay. It’s the closest thing to a tell-all biography he’s ever put on record.

“I’ve never been so open, for so long . . . it makes people uncomfortable,” Jay (aka Shawn Carter) told the Rap Radar podcast in 2017. That honesty, coupled with the album’s rich, soulful textures and samples conjured up by producer No I.D. (aka Ernest Dion Wilson), has rightly seen the 48-year-old restored as one of the world’s most prominent rappers.

“So many entertainers are forced to wear masks and facades on stage, in front of the world,” No I.D. tells The Post. “This album put people in the music world on notice. It was like, ‘Hey, one of the most successful guys in our business has decided to be as real as possible. What are you gonna do?’ ”

Recording of “4:44” began in early 2017 in a Los Angeles studio, and the first two songs Jay worked on kick off the album: “Kill Jay Z” and “The Story of O.J.” The former finds Hova stripping back his public image and confronting past misdeeds, including nonfatally shooting his own crack-addicted older brother, Eric, when Jay was just 12 years old. The latter is a sage reflection on how even the most successful of African-Americans can never truly escape their race — whether they want to admit or not. “O.J. like, ‘I’m not black, I’m O.J.’ . . .” he raps at one point, leaving a pregnant pause before delivering a deeply skeptical “OK.”

Immediately, No I.D. realized this wasn’t going to be a standard hip-hop album. “I knew he wanted to tackle some deeper issues,” he says. “As a producer, I was pushing for, ‘Let’s not think about radio, or the club.’ There’s a lot of that already.”

“This is a storytelling album,” adds Jimmy Douglass, another longtime Jay-Z collaborator who mixed “4:44.” “The music is meant to be an accompaniment to the narrator.”

As the album developed, it was clear that Jay-Z intended to go not only outside of his own comfort zone, but also to places where his family might also feel uneasy. On the track “Smile,” which features a spoken-word contribution from his mother, Gloria Carter, Jay acknowledges her long struggle with her closeted sexuality, stating, “Mama had four kids but she’s a lesbian/Had to pretend so long she’s a thespian.”

Perhaps unsurprisingly, that eye-widening line was first met with resistance from Gloria. “When she first heard the song, she was like ‘absolutely not,’ ” Jay told Rap Radar. “I said, ‘Man, this is so important. So many people in the world [are] hiding.’ ”

“Jay and Gloria did their talking outside the studio,” recalls No I.D. “There was no portion that I thought was exploitative. It was all from the perspective of being helpful. The music that lasts decades and centuries is songs that have that level of courage.” Gradually, Jay talked his mother around, and the result is unquestionably one of the most uplifting moments on the album.

But Jay and Gloria weren’t the only ones locked in deep conversation during the making of this album. Inside the studio, Jay and the rest of his inner circle would often engage in long discussions that were inspired by, but would also inform, the material. “One of the conversation topics that looms over the whole project is, ‘What is wealth?’ ” says No I.D. “Without family, it’s a short-sighted wealth because real wealth runs through generations.”

It’s something that Hova — whose net worth Forbes estimated to be more than $800 million in 2017 — expresses in the final track, “Legacy.” The song starts with Jay and Beyoncé’s firstborn, Blue Ivy, asking, “Daddy, what’s a will?” before Jay expresses his aspirations for the Carter fortune, acknowledging his own responsibility to preserve it. “Generational wealth, that’s the key/My parents ain’t have s - - t, so that shift started with me.”

While it’s true that such talk of wills, wealth and family might not go down too well with the teenagers of the world, that was almost entirely the point. Even if it Jay-Z doesn’t walk away with a single Grammy on Sunday, “4:44” has redrawn the boundaries of hip-hop, and shown that the genre doesn’t always have to be a young person’s hustle.

“Most rappers of his generation fell by the wayside and didn’t get to stay in the game,” says Douglass. “But he’s still there, holding a sword in the battlefield. With this album, Jay went places that no man has ever gone before.”