Dec 29 (Reuters) - Wall Street’s main indexes were little changed on the last trading day of 2017, but were still on track to record hefty gains for the year.

Consumer staples companies, including Altria, Coca-Cola and Philip Morris, gained between 0.5 percent and 1 percent in thin holiday trading ahead of the New Year.

Heavyweights Apple, Amazon and Goldman Sachs were a drag on the indexes.

Strengthening global economy, solid corporate earnings and low interest rates have helped the benchmark S&P 500 lock in 20 percent gains for the year, while feeding into a nine-year old rally in global stocks.

The market has also shown surprising strength despite tensions in North Korea and political upheavals in Washington. The S&P has closed below 1 percent only four times this year.

The rally is widely expected to extend into 2018, boosted by gains from a new law that lowers the tax burden on U.S. corporations.

“If you asked any of us on Jan. 1 what would happen with the market if none of those policies went through, we would’ve expected a poor performance. Surprisingly, the earnings picture also came to the upside,” said Luke Tilley, chief economist at Wilmington Trust in Wilmington, Delaware.

“We’re not very optimistic that we’ll have another year like we did in 2017, not that valuations portend a major catastrophe.”

The S&P technology index has been the best performing sector, rising about 37 percent and outpacing gains in the broader index.

Telecom services and energy are the only two sectors to end the year lower among the 11 major S&P indexes.

At 9:35 a.m. ET (1435 GMT), the Dow Jones Industrial Average was up 11.25 points, or 0.05 percent, at 24,848.76 and the S&P 500 was up 2.29 points, or 0.08 percent, at 2,689.83.

The Nasdaq Composite was up 0.19 points, or 0 percent, at 6,950.35.

Six industry sectors were higher on Friday, led by 0.3 percent gain in the consumer staples index.