We analyse differently "a blue book" and "a grammar book" in English.
"Grammar book" is a compound noun composed of two nouns. There is a rule in English that says that you can build compound nouns this way, the noun that qualifies the other noun comes first.
In such a case in French we cannot build a compound noun, we have to use a periphrase and link the two nouns with a preposition. The nouns that qualifies the other comes second.
Un livre de grammaire → a grammar book
Des chaussures de tennis → tennis shoes
Une tasse à café → a coffee cup
The fragment "a blue book" is not a compound noun but a noun that is qualified by an adjective, in English the attributive adjective comes in front of the noun, in French the attributive adjective comes either before or after the noun. In the case of bleu it comes after the noun1.
Un livre bleu → a blue book
Des chaussures confortables → comfortable shoes
Une vieille maison → an old house
So, to answer your question, in order to know what to say in French I expect the best is to analyse the grammar and find out if you have a noun that qualifies another noun or an adjective that qualifies a noun.
1 Knowing where to place the attributive adjective in French is another story. This can easily be found in grammar books, and there have been numerous questions asked on this site, for instance here.