Token is an essential module available for both versions of drupal, There are lots of other modules that are dependent on the token module. it provides us global replacement patterns/tag, and so tokens provide us dynamic values. There is a list of global tokens available in token module and other popular modules also define their own tokens which help site builders to get dynamic values. Sometimes we may need to define our own token and replacement patterns.
I believe you all know the Drupal 8 module structure, so let's start with the important code. We are going to use two important hooks in our example
- hook_token_info
- hook_tokens