Sitemap error

#972289
  • Resolved Tadej Guzelj
    Rank Math free

    I have website: https://www.elevonx.com/

    My sitemaps gets error: https://www.elevonx.com/sitemap_index.xml

    But my html sitemap page works great: https://www.elevonx.com/sitemaps/

    Can you maybe helm me fix the issue.
    I tried to disable all other plugins and I still have an error.
    I am using divi theme and child theme
    Even if I change theme to some third still get the same error.

    ERROR:
    This page contains the following errors:
    error on line 2 at column 6: XML declaration allowed only at the start of the document
    Below is a rendering of the page up to the first error.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    We apologize for the issue you are facing with your sitemap. The error message you are seeing, "XML declaration allowed only at the start of the document," typically indicates that there is some output (like whitespace or HTML) before the XML declaration in your sitemap file.

    Here are a few steps you can take to troubleshoot and potentially fix this issue:

    1. Check for Whitespace: Ensure that there are no spaces or new lines before the ` declaration in your sitemap file. This can often happen if there is an extra line in your theme'sfunctions.php` or any other PHP file that outputs content.

    2. Disable Caching: Since you mentioned that you have already disabled other plugins, ensure that any caching mechanisms (including server-side caching) are also disabled. You can try adding the following filter to your theme’s rank-math.php file to disable caching for the sitemap:

      add_filter( 'rank_math/sitemap/enable_caching', '__return_false' );

      Make sure to clear your website cache after making this change.

    3. Check for Output from Other Plugins: Sometimes, other plugins might inadvertently output content before the XML declaration. You can use the Health Check plugin to troubleshoot this by enabling troubleshooting mode and disabling all plugins except Rank Math.

    4. Review Your Theme Files: Since you are using a child theme, ensure that there are no modifications in your child theme that could be affecting the sitemap output. You might want to temporarily switch to a default theme (like Twenty Twenty-One) to see if the issue persists.

    5. Check Server Configuration: In some cases, server settings or configurations can lead to unexpected output. If you have access to your server logs, check for any errors that might indicate what is causing the output before the XML declaration.

    If these steps do not resolve the issue, please reply to this ticket with any additional details or errors you encounter, and a human agent from our support team will assist you further. Thank you for bringing this concern to our attention!

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Tadej Guzelj
    Rank Math free

    where do I paste:
    add_filter( ‘rank_math/sitemap/enable_caching’, ‘__return_false’ );
    I don t have that file in theme files.

    I tried all the things but no sucess

    Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    We checked your sitemap and we can see that it is working fine now:

    Rank Math support

    Rank Math support

    As for applying the filter code to your website, please follow this guide: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how that goes.

    Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Sitemap error’ is closed to new replies.