@RequestMapping(value = "", method = GET)
  public String index(Model model) {

    List<Map<String, Long>> counts = postService.countPostsByTags();

    model.addAttribute("tags", counts);

    return "tags/index";
  }
  @RequestMapping(value = "{tagName}", method = GET)
  public String showTag(
      @PathVariable String tagName, @RequestParam(defaultValue = "1") int page, Model model) {
    Tag tag = tagService.getTag(tagName);

    if (tag == null) {
      throw new NotFoundException("Tag " + tagName + " is not found.");
    }

    page = page < 1 ? 0 : page - 1;
    Page<Post> posts = postService.findPostsByTag(tagName, page, appSetting.getPageSize());

    model.addAttribute("tag", tag);
    model.addAttribute("posts", posts);
    model.addAttribute("page", page + 1);
    model.addAttribute("totalPages", posts.getTotalPages());

    return "tags/show";
  }