Hi @baoyu_li
You can enable context hub by adding the below line of code in head.html of your page component.
<!--/* Include Context Hub */-->
<sly data-sly-resource="${'contexthub' @ resourceType='granite/contexthub/components/contexthub'}"/>
*/-->
You can create the context hub configuration by navigating from Tools -> Configuration Browser -> Select the project folder -> Enable Context Hub checkbox.
This will create the basic config here /conf/project/settings/wcm/segments
Now you can add your segment nodes under the above path.
Please refer the document below:
https://experienceleague.adobe.com/docs/experience-manager-learn/sites/personalization/context-hub-t...
Thanks!