Karl Marx's famous "The German Ideology" opens with a full-front offensive on the Hegelian tradition on 19th century idealist German philosophers. The Hegelian philosophers focused on consciousness and abstract ideas, holding that they have independent existence which shapes social reality (hence the term "idealist philosophy"). According to this view, a change in social reality can be brought about through a change in the manner this reality is perceived.
In "The German Ideology" Marx offers an opposite analysis, manifested in his materialist approach that sees different ideas and perceptions as the result of material social, economical and historical conditions. In other words, for Marx in "The German Ideology" it is reality which creates the mind, and not the other way around.
According to Marks, various positions and beliefs held by people, be it religious, moral and so on, are created and conditioned by their material circumstances. This is true, as Marx points elsewhere, to both historical circumstances and class, social and economical circumstances (and here we can see why "class consciousness" is such an important term in Marx's philosophy).
The argument that consciousness in socially constructed was raised before Marx, but it was Marx in The German Ideology who made it the foundation of his social philosophy. Marx draws heavily (and criticizes just as heavily) on the work of Feuerbach who claimed that religious faith is rooted in man's actual and material conditions, in man's perception of himself and in that god is but a projection of his earthly creators (Emile Durkheim argued something similar in his notion of the "totemic principle"). However, this is not material enough for Marx who thinks that Feuerbach failed to bring into account specific social, economical and historical conditions which shape religious belief.
For Marx it is not enough to claim that people create their own images, ideologies and so forth, as suggested by Feuerbach and others. For Marx in "The German Ideology" people's ideas and ideologies are conditioned by the historical formation of powers of production and relations of production (these ideas by Marx are elaborated later in "The German Ideology"). This is the ground for Marx's famous distinction between economical base (which includes the forces of production, relations of production and division of labor) and the "superstructure" which includes culture, ideology, religion etc. for Marx, the superstructure is determined by the material base, and not as the Idealist philosophers would have it.
Additional summeries of The German Ideology by Marx: