Cesar Hernandez and Carlos Santana also homered for the Phillies, who scored 10 or more runs for the third time this season, to reward the strong pitching of Zach Eflin (1-0) and three relievers.
The loss snapped San Francisco's four-game winning streak.
The Phillies wasted no time jumping on Giants starter Jeff Samardzija (1-2), aided by eight- and six-pitch walks, respectively, to Hernandez and Rhys Hoskins to open the bottom of the first.
Herrera then belted the first pitch he saw over the fence in right-center field for a three-run homer.
Hernandez launched his fourth homer of the season, a two-run shot, in the fourth, and Santana added a three-run blow, his fourth, in the fifth, extending the lead to 8-0.
Herrera made it a two-homer game for the second time this season with a two-run shot in the sixth that made it 10-0.
Herrera's other two-homer game came against Atlanta on April 27.
Samardzija was pulled after four innings, having allowed the first two homers and five runs in all. He gave up four hits and three walks while striking out three.
The Giants had allowed no more than five runs in any of their previous eight games.
Making just his second start of the season after beginning the year in the minors, Eflin shut out the Giants on four hits over 6 2/3 innings. He walked three and struck out nine.
The right-hander had pitched well, but without a decision, in his season debut last Tuesday, allowing just one run and three hits in six innings against the Miami Marlins.
Zac Curtis, Seranthony Dominguez and Yacksel Rios worked the final 2 1/3 innings for the Phillies, allowing two hits and one walk while completing the club's fourth shutout of the season.
Dominguez, 23, pitched a perfect eighth inning in his major league debut.
Santana made it a four-RBI game with an infield out that scored Pedro Florimon, who had doubled, to complete the scoring in the eighth.
Herrera scored three times and had five RBIs for the Phillies, who have alternated wins and losses in their past six games.
Hernandez and Hoskins scored twice apiece, while Nick Williams had two hits for Philadelphia, which was opening a seven-game homestand.
Buster Posey had two hits for the Giants, who had opened their 10-game trip with a three-game sweep at Atlanta.
--Field Level Media
San Francisco | Philadelphia | |
Jeff Samardzija | Player | Zach Eflin |
Loss | W/L | Win |
4.0 | IP | 6.2 |
3 | Strikeouts | 9 |
4 | Hits | 4 |
11.25 | ERA | 0.00 |
San Francisco | Philadelphia | |
Buster Posey | Player | Odubel Herrera |
2 | Hits | 2 |
0 | RBI | 5 |
0 | HR | 2 |
2 | TB | 8 |
.667 | Avg | .667 |
Team | Hits | HR | TB | Avg | LOB | K | RBI | BB | SB | Errors |
San Francisco | 6 | 0 | 7 | .188 | 19 | 12 | 0 | 4 | 0 | 3 |
Philadelphia | 12 | 4 | 25 | .316 | 17 | 6 | 11 | 4 | 2 | 0 |