Yes, you can travel outside Canada while studying on a study permit. However, it's important to travel with the correct documents (such as a valid Temporary Resident Visa (TRV) or Electronic Travel Authorization (eTA) depending on your country of citizenship, a valid passport, study permit), to re-enter Canada. Be sure to check your document expiry dates and renew them if necessary before you travel. Please remember that the final decision regarding entry to Canada is at the discretion of the CBSA Officer at the port of entry.
Note: If you plan to travel while your classes are in session, it is your responsibility to inform your professors in advance and make arrangements with them (if possible) regarding missed coursework/assignments while you are away.