Sitemap Error

#819275
  • Resolved Gianclaudio
    Rank Math free

    Hello, I’m trying to generate a sitemap, but i receive this error: “error on line 1 at column 7: XML declaration allowed only at the start of the document”. I Checked Function.php and WpConfig.php, but is all ok.
    I tryed everything but nothing works.
    Can you please help me?
    If you need other details, I’m here!

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

    I’m sorry to hear that you are facing issues with generating your sitemap and receiving the error message "error on line 1 at column 7: XML declaration allowed only at the start of the document."

    This error typically occurs when there are white spaces or characters before the XML declaration in the sitemap file. Since you have already checked the functions.php and wp-config.php files, the issue might be related to a plugin conflict or caching interference.

    To troubleshoot this further, please follow these steps:

    1. Check for any plugin conflicts using the Health Check plugin as mentioned in our KB article here.
    2. Ensure that your caching is disabled, as caching can sometimes interfere with the sitemap functionality of Rank Math.

    If the issue persists after following these steps, please provide more details about your setup so we can assist you further. Thank you for your patience and cooperation.

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math

    I tryed your suggestion, but nothing happens.
    Can you help me?
    Thanks!

    Hello,

    Thank you for your patience.

    In this case, please follow these steps to flush your sitemap cache:

    1. Flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    3. Disable the transient cache for the sitemap by applying this filter. This will make sure that your XML sitemap always reflects the latest changes on your site:

    /** 
     * Filter if XML sitemap transient cache is enabled.
     *
     * @param boolean $unsigned Enable cache or not, defaults to true
     */
    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    If you’re not sure how to add this code, you can follow this guide:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    If the issue persists, then you may follow this guide to fix this issue on your sitemap:
    https://wejn.org/stuff/wejnswpwhitespacefix.php.html

    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.