Non-native speaker here.

#### First choice: How do I ...

On a question-answering site, ask questions in proper English, and at best as if you would ask someone right away, since that is what lets you aim at an answer, and that is what makes it clear on a first glimpse what the question aims at - an answer.

That is why you should not write "How to ...?", which is not 100-percent-proper English - see the remark under the question at ["How to ... ?" questions might be wrong grammar. Will it help dropping the question mark for all questions or warning the user or something the like?](https://meta.stackexchange.com/questions/398259/how-to-questions-might-be-wrong-grammar-will-it-help-dropping-the-quest):

> It may not be 'proper' according to some, but it works.

Ask "How do I" / "How can I", which keeps it short and clear, and it is the main way how the people write down their search in the search engines.

#### Second and last choice: Blog-style "How to ... [without a question mark]" / gerund

If your question builds up a frame of a sort of technical writing, perhaps a self-answered question, a guide or some code that needs to be checked, you *may* (but rather should not) switch to a blog-style "How to ..." (*without* a question mark at the end) or a gerund. Both are no questions. That is why they do not fit well enough to a question-answering site.