Hello @fulongt37334138
If you are trying to identify that the resource is rendered from a template or a Page, then you can create a utility function like this
public static boolean isTemplateResource(Resource resource){
if (resource == null) {
return false;
}
String path = resource.getPath();
boolean isTemplatePath = (path.startsWith("/conf/") && path.contains("/settings/wcm/templates/"));
return resource instanceof TemplatedResource || isTemplatePath;
}
It would really be helpful, if you can help us understand the use-case. Just FYI, page and templates are tied via a cq:template property. See if that helps !