# How make custom Liquid tag append to page.tags

**URL:** <https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409>\
**Category:** Help\
**Created:** [July 22, 2023, 3:38pm UTC](https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409 "2023-07-22T15:38:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlconlin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jlconlin/32/2845_2.png) [@jlconlin](https://talk.jekyllrb.com/u/jlconlin)\
**Post date:** [July 22, 2023, 3:38pm UTC](https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409/1 "2023-07-22T15:38:31Z")

</div>

I have a custom Liquid tag that (in addition to customizing the look) I want to add to the array of `page.tags`. The first couple of lines of the `render` function (shown below) is supposed to do that. It works when I do a fresh build of the site. When I do an incremental build, it does not.

It seems I’ve created a hack that doesn’t quite work correctly. **Please help me know what I’m missing.**

```auto
module Jekyll
  class Term < Liquid::Tag
    def initialize(tag_name, input, tokens)
      super
      vars = input.split(" ")
      @acronym = vars[0]
      @category = vars[1]
    end

    def render(context)
      tags = context.environments.first['page']['tags']
      tags.append(@acronym) unless tags.include?(@acronym)

      begin
        definition = context.registers[:site].data['terminology']["#{@category}"]["#{@acronym}"]['definition']

        if definition.nil?
          "<a style=\"color:red\" href=\"/terminology/#{@category}\##{@acronym}\" title=\"???\" class=\"term\">#{@acronym}</a>"
        else
          "<a href=\"/terminology/#{@category}\##{@acronym}\" title=\"#{definition}\" class=\"term\">#{@acronym}</a>"
        end
      rescue NoMethodError
        "<span style=\"color:red\">#{@category}/#{@acronym}</span>"
      end
    end
  end
end

Liquid::Template.register_tag('term', Jekyll::Term)

```

---

<div class="post-metadata">

**Author:** ![pcouy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pcouy/32/5307_2.png) [@pcouy](https://talk.jekyllrb.com/u/pcouy)\
**Post date:** [July 23, 2023, 1:44pm UTC](https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409/3 "2023-07-23T13:44:15Z")

</div>

If by “incremental build” you mean using the `--Incremental` flag as in `jekyll serve --incremental` you should be aware that [this feature is still experimental](https://jekyllrb.com/docs/configuration/incremental-regeneration/#incremental-regeneration) and does not work well.

By just running `jekyll serve`, jekyll should be able to pick up any modification you made to your website and rebuild accordingly.

---

<div class="post-metadata">

**Author:** ![jlconlin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jlconlin/32/2845_2.png) [@jlconlin](https://talk.jekyllrb.com/u/jlconlin)\
**Post date:** [July 24, 2023, 1:05pm UTC](https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409/4 "2023-07-24T13:05:11Z")

</div>

I had forgotten that incremental was still experimental. Thanks for the reminder.

---

<div class="post-metadata">

**Author:** ![pcouy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pcouy/32/5307_2.png) [@pcouy](https://talk.jekyllrb.com/u/pcouy)\
**Post date:** [July 24, 2023, 9:15pm UTC](https://talk.jekyllrb.com/t/how-make-custom-liquid-tag-append-to-page-tags/8409/5 "2023-07-24T21:15:32Z")

</div>

This is an easy mistake to make since this is so poorly documented and `jekyll serve` suggests in its output that you use this flag
