Connecting main clauses with "deshalb" und "trotzdem"

German has some adverbs that can be used to connect two independent clauses. They are called conjunctive adverbs. They have similar functions and meanings to conjunctions, but differ grammatically.

"deshalb" (therefore) is an adverb that indicates a reason for something like the conjunctions "denn" (for) and "weil" (because). So "deshalb" answers the question "Warum?" (why?) and creates a causal relationship between the two clauses. But the word order is different for all three:

"denn" is a coordinating conjunction that introduces a second, explanatory main clause. The word order of the second main clause doesn't change.

"weil" is a subordinating conjunction that introduces a dependent clause with explanatory information about the clause to which it refers. The conjugated verb moves to the end of the subordinate clause.

"deshalb" is an adverb that connects two main clauses. But in this case, the explanatory part comes first and "deshalb" precedes the actual action, statement or fact of the sentence. Also, the conjugated verb comes directly after it in the second position.

Fact/action         Reason
Ich trinke ein Kölsch,     denn   ich bin ein Kölner.
Ich trinke ein Kölsch,   weil   ich ein Kölner bin.
         
Reason        
Ich bin ein Kölner,   deshalb   trinke ich ein Kölsch.

"trotzdem" (nonetheless) is an adverb that indicates a contradiction like the conjunction "obwohl". The sentence structure here is the same as above.

Fact/action        Contradiction
Ich trinke ein Bier,    obwohl   ich lieber Wein mag.
         
Contradiction       Fact/action
Ich mag lieber Wein,   trotzdem   trinke ich ein Bier.

In compound sentences that contain conjunctive adverbs to connect clauses, the two main clauses can be separated by a comma or a period. Even if they are separated by a period, the conjugated verb keeps its position after the adverb.

Examples:
Ich mag lieber Wein, trotzdem trinke ich ein Bier.
Ich mag lieber Wein. Trotzdem trinke ich ein Bier.