Creating the URL of a community or organization

Ok, this is a short one and it is more like a reminder for myself.
This is how you get the relative URL that points directly to a community or organization page:

public static String createLinkToGroup(Group group, Layout layout){
  boolean privateLayout = layout.isPrivateLayout(); 
  String privateSelector = privateLayout ? "group" : "web";
  String link ="/" + privateSelector + group.getFriendlyURL() + layout.getFriendlyURL(); 
  return link;

If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.