How to Index the Contents of an iframe
When your primary page integrates a sub-page through an iframe, you need to think about how search engines handle the content. Although search engines try to associate the sub-page content with the primary page, it isn’t guaranteed. This uncertainty arises because both pages are treated as individual HTML entities.
Cross-Domain Iframes and Indexing Control:
- To influence the indexing behavior, you can use a combination of meta tags and HTTP headers:
- Meta Tags for Indexing Control:
- On the sub-page, you can include meta tags to guide search engines. If you want to ensure that the sub-page is only indexed as a part of the primary page, use the following meta tags:
<meta name="robots" content="noindex, indexifembedded">
- The “noindex” tag prevents standalone indexing, and “indexifembedded” suggests that indexing is allowed when embedded within another page.
- HTTP Header for X-Frame-Options:
- To prevent the sub-page from being embedded via iframe elements and ensure it’s not indexed as a part of the primary page, set the appropriate
X-Frame-Options
in the HTTP header: X-Frame-Options: DENY
- This header instructs browsers not to display the sub-page in a frame, preventing it from being indexed as part of the primary page.
- To prevent the sub-page from being embedded via iframe elements and ensure it’s not indexed as a part of the primary page, set the appropriate
- Meta Tags for Indexing Control: