Updated

Ryan Vogelsong had another dominating home outing Tuesday and helped the Giants further tighten the race against the sputtering Dodgers in the NL West.

The 34-year-old spun seven innings of shutout ball, while Melky Cabrera smacked a solo homer as part of a two-run fourth inning, as San Francisco blanked Los Angeles for the second straight night, 2-0, in the middle test of a three-game set.

It's the first time that the Giants have registered back-to-back home shutouts against the Dodgers since 1987.

Vogelsong (7-3) scattered seven hits and walked one for the Giants, who are just a game back of the Dodgers and have won 12 of their past 17 home tilts against their fierce rivals.

"Pitching has been right on in this series," Giants manager Bruce Bochy said. "Vogy (Vogelsong) is pretty amazing what he has done and how consistent he's been...He knows what he's doing."

Since the start of the 2011 season, Vogelsong owns a sparkling 1.85 ERA at home. Only Jered Weaver (1.55) owns a lower home ERA during that span.

A winner in each of his past four starts at AT&T Park, Clayton Kershaw (5-4) was charged with two runs on eight hits and two walks in six innings for Los Angeles, which has dropped seven of its last eight contests.

"It's just a matter of us staying the course," Dodgers manager Don Mattingly said of his team's struggles. "It's my job as a manager that we don't panic."

The only runs in the game came in the fourth. Cabrera ripped a leadoff shot into the seats in left to give the Giants a 1-0 lead.

Buster Posey then singled and Angel Pagan grounded into a fielder's choice. Pagan swiped second and scored on Pablo Sandoval's single to right. Brandon Belt followed with a double, but Kershaw was able to limit the damage from there.

After he intentionally walked Joaquin Arias to load the bases with one out, he struck out Vogelsong and Gregor Blanco to end the threat.

Jeremy Affeldt tossed a 1-2-3 eighth and Santiago Casilla worked around a one- out walk in the ninth for his 21st save of the season.

Game Notes

Kershaw had gone 6-0 with a 0.88 ERA in his last seven starts against San Francisco...The Giants were 1-for-10 with runners in scoring position while Los Angeles was 0-for-5.