# أضف محتوى ديناميكي إلى \<head\> - AMP - أي نصائح؟

**URL:** <https://meta.discourse.org/t/add-dynamic-content-to-head-amp-any-tips/143815>\
**Category:** Support\
**Created:** [10 مارس 2020، 3:50م UTC](https://meta.discourse.org/t/add-dynamic-content-to-head-amp-any-tips/143815 "2020-03-10T15:50:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Bcat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bcat/32/163148_2.png) [@Bcat](https://meta.discourse.org/u/Bcat)\
**Post date:** [13 مارس 2020، 2:18ص UTC](https://meta.discourse.org/t/add-dynamic-content-to-head-amp-any-tips/143815/3 "2020-03-13T02:18:28Z")

</div>

استخدمت:

```plaintext
<script type="text/discourse-plugin" version="0.8">
    api.onPageChange((url, title) => {
        var res = url.match(/\/t\/(.*?)\/(\w+)/);
        if (res && res[2] > 0) {
            var amp = 'domain/amp/t/'+res[2];
            if (document.getElementById("amphtml")) document.getElementById("amphtml").href = amp;
            else{
                var link=document.createElement('link');
                link.id='amphtml';
                link.rel='amphtml';
                link.href=amp;
                document.getElementsByTagName('head')[0].appendChild(link);
            }
        }
    });
</script>

```

لكن عند عرض المصدر لا يظهر، بل يظهر فقط عند تنفيذ جافا سكريبت.  
فكيف يمكن عرضها من البداية؟

* * *

13-03-20

حاولت التعديل بإضافة `<xhtml:link rel="amphtml" href="" />` إلى خريطة الموقع.  
نموذج: [GitHub - bcat95/discourse-sitemap: Generate XML sitemap for your Discourse forum. · GitHub](https://github.com/bcat95/discourse-sitemap)

14-03-20

**نجح الأمر، حيث بدأت جوجل في فهرسة صفحات AMP**

---

_[View the full topic](https://meta.discourse.org/t/add-dynamic-content-to-head-amp-any-tips/143815)._
