<p>As Brad kindly pointed out, I checked my files in the <code>config</code> directory and noticed a few spaces before I started the <code>&lt;?php</code> in my <code>/craft/config/imager.php</code> file. I would never have thought to check this, so thanks Brad!</p>

CC BY-SA 4.0
2020-05-15T01:22:37.690Z
Lifesaver! I had the same issue and the volumes.php file had a couple of white spaces in the beginning too.
Mark Busnelli Jr
CC BY-SA 4.0
2018-10-16T08:09:58.807Z
2018-10-16T08:09:58.807Z
Mark
<p>There is white space being added to the start of my templates.</p>

<p>This isn't really an issue but because its happening to an RSS template that is breaking the feed and causing it to not validate.</p>

<p>When I edit the template in my text editor the white space is not there, so I think it is Craft adding when when rendering the template?</p>

<p>My code looks like this, you can see on line 1 there are no spaces before I declare the XML version. <code>&lt;?xml</code></p>

<p><a href="https://i.sstatic.net/8vHfg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8vHfg.png" alt="RSS template start"></a></p>

<p>However, on the front end it is rendering like so: I have highlighted the space in blue.</p>

<p><a href="https://i.sstatic.net/mbNut.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mbNut.png" alt="White space being added to RSS doc"></a></p>

<p>Because of this, the RSS template is not validating and is causing my feed to break.</p>

<p>This started recently, I am not sure if it is linked to a recent Craft update but it started happening around the same time.</p>

<p>Craft v3.0.26.1</p>

<p>Any help appreciated :) Thanks</p>

CC BY-SA 4.0
2018-10-15T08:54:58.433Z
If I simply drop a test.html file in the public root its not the case. It only occurs when the template is in the templates directory
Mark
CC BY-SA 4.0
2018-10-15T17:44:16.137Z
It's not just your main template that could be injecting extra whitespace... it could be coming from included templates. Also, check your public index.php file, your files in `craft/config/*` and other other files you might have editing that would be included in that RSS feed request.
Brad Bell
CC BY-SA 4.0
2018-10-16T07:43:13.827Z
@BradBell Thanks for the heads up, there was a couple of spaces at the start of my `craft/config/imager.php` file.
Mark
<craft3><rss><whitespace>
White space added to start of template's
# White space added to start of template's

(Asked by: username_0 on 2018-10-15)

There is white space being added to the start of my templates.

This isn't really an issue but because its happening to an RSS template that is breaking the feed and causing it to not validate.

When I edit the template in my text editor the white space is not there, so I think it is Craft adding when when rendering the template?

My code looks like this, you can see on line 1 there are no spaces before I declare the XML version. `xml</code`

[![RSS template start](https://i.sstatic.net/8vHfg.png)](https://i.sstatic.net/8vHfg.png)

However, on the front end it is rendering like so: I have highlighted the space in blue.

[![White space being added to RSS doc](https://i.sstatic.net/mbNut.png)](https://i.sstatic.net/mbNut.png)

Because of this, the RSS template is not validating and is causing my feed to break.

This started recently, I am not sure if it is linked to a recent Craft update but it started happening around the same time.

Craft v3.0.26.1

Any help appreciated :) Thanks

**Tags:** craft3, rss, whitespace

> **Comments:**
> **username_0**: If I simply drop a test.html file in the public root its not the case. It only occurs when the template is in the templates directory  
> **username_1**: It's not just your main template that could be injecting extra whitespace... it could be coming from included templates. Also, check your public index.php file, your files in `craft/config/*` and other other files you might have editing that would be included in that RSS feed request.  
> **username_0**: @BradBell Thanks for the heads up, there was a couple of spaces at the start of my `craft/config/imager.php` file.  

---

## 1 answers

### Answer by username_0 on 2018-10-16. Score: 2 | Accepted answer

As Brad kindly pointed out, I checked my files in the `config` directory and noticed a few spaces before I started the `php</code in my /craft/config/imager.php file. I would never have thought to check this, so thanks Brad!`

> **Comments:**
> **username_2**: Lifesaver! I had the same issue and the volumes.php file had a couple of white spaces in the beginning too.  

---

