Is it ethical to publish homework?
Sometimes when doing course work for university, I'd like to write about it on my website, or publish it in its entirety, because I think that other people might be interested in it.
This re-enforces your learning BUT will current students have access to it.
Once, a student from my University did this, and someone else copied from her. There was a big mess about this. Fortunately the student got a passing grade for the class.
and most courses reuse homework questions and paper topics over multiple years.
and
So my question is if it would be ethical for me to do so, and under which circumstances.
Instead of using exact question answer, can you create similar question and give solution. This way you are tutoring other people and making them think (and making yourself think), rather than giving the answers to students who just want to pass the class and forget what they "learned".
In brief, I claim that this should not be a question a student has to comtemplate... So, operationally, the answer is "no, it is not unethical, but it may be against the (unreasonable, indefensible) rules to an extent that will create fatal trouble for you..." So, no, it's not unethical, but probably often "seriously illegal", dangerously to you, though it should not be.
The points the other answers have made are "not unreasonable", but, I claim, essentially untenable. That is, if there are indeed very few tasks whose performance could be "tested", example executions will certainly exist "in the wild", whether or not a student in a specific class puts their own solution on-line. Although I'm thinking primarily about a mathematics environment, I'm well-enough acquainted with CS issues to not feel too out-of-it in thinking about such issues, as well. Indeed, the number of "stock" issues in both cases seems similar ... and small. That is, there is a greater underlying issue, that the number of reasonable, answerable questions (apart from trivial variations) is very small, and a conscientious person can merely collect "solutions", rather than think them through themself.
To my mind that is the "real issue", if it is an issue at all. That is, we might take the poverty-of-variation as a signal that pretending to keep some trivial idea secret so as to "test" on it is perverse!?!
There are two fundamentally conflicting issues: promoting understanding and scholarship, versus arranging convenient "testing" for various purposes. "Convenient testing" prefers as many secrets as possible, obviously. Promoting understanding would exactly want to explain to interested parties how to resolve issues raised... among other places ... in the "tests".
Some events that finally "got through to me" about this, some years ago, involved my colleagues firm admonishments that "approved solutions" for (graduate) Qualifying Exams should never be published, because otherwise the students would learn how to do those problems... uh... whah? :) Ok, even if we "buy" that for a moment, one can observe that then bad "solutions" are the only ones available, so people study from bad material... ?!?!
The meta-comment is that many "educational" institutions have not-at-all figured out how to cope with the fluidity and availability of information, and, instead, try to prohibit all the obvious "new" avenues, simply to avoid change. While it is arguably true that the motivations of some students may not be the most honorable, I am absolutely not in favor of sting operations that declare them guilty of serious malfeasance by "using the internet" or "telling people what they know", and so on. That'd be perverse. Instead, things need to be reconstituted so that "keeping secrets" is not an essential part of appraising competence.
Summary: it's not at all unethical, but it may be so illegal that you must ask your local authorities. (Yet, again, while it's good to ask, it is terrible that there is an issue here...)
In my opinion there is nothing wrong with publishing solutions to (interesting) questions/exercises on one's own page, given that there is no explicit policy against doing so at your university.
I never heard of a policy forbidding publication of answers at my university and the general approach in our group is that students may very well learn something even from reproducing solutions of others. Specifically for physics (my subject) there is a set of problems which come up in certain variations over the years and by looking hard enough you'll find an answer (or at least an outline of a solution) for almost any problem.
My personal position is that the students are old enough to get a grip on reality and understand, that if they just copy solutions they are doing themselves a disservice in the long run. At some point in time the missing methodology will come to bite them in the a**.
TL;DR students should be mature enough to understand that 1:1 copying is more harmful than usefl. We (as TA's) are not their nannies.