If user text becomes a query parameter, encode it as a parameter value so characters such as &, ?, spaces, and non-ASCII letters do not change the URL's structure. For example, a search value of cats & dogs must not create a second parameter by accident.
Use a URL-building API when possible; it handles separators and encoding more reliably than string concatenation. The URL encoder can help inspect a value, but do not encode an entire URL when you mean to encode only one component. Avoid double-encoding % sequences and test the decoded value at the destination.
URL encoding does not make a link safe or secret.