Alternative Language links are not forming properly
I'm working on AEM as cloud service, we are using OOTB functionality for alternative links in our head.link.html file.
<link data-sly-test="${page.alternateLanguageLinks}" data-sly-repeat="${page.alternateLanguageLinks.entrySet}" rel="alternate"
hreflang="${item.key.toLanguageTag}" href="${model.hostName}${item.value @ extension}">
above code is not working properly, Sometimes it return 3 locale pages only where it should return 4 and sometimes it return empty.
Note:- I have enabled the checkbox (render alternative language links) in template page policy. Also other locale pages are created using OOTB AEM language copy option only.
Can anyone suggest what could went wrong? or any other approach to render alternative language links?