Pass custom variable to view Coming from a Yii2 background, I am accustomed to doing things in an MVC way.

I have set up a demo Craft CMS application to have a play around with. I've created a "singles" page (homepage) and got it displaying data. What I want to know is, how do I pass custom variables to the view?

For example I have a function that fetches tweets from my Twitter account, I would like this data to be displayed on the homepage. In Yii2 I would normally do the following:

&lt;?php

namespace app\controllers;

use yii\web\Controller;
use app\services\TwitterFeedService;

class SiteController extends Controller
{
    public function index()
    {
        $twitterFeed = TwitterFeedService::getTweets();

        return $this-&gt;render('index', [
            'twitterFeed' =&gt; $twitterFeed,
        ]);
    }
}


But since there is no controller or action for my homepage at the moment, I am not sure how I would go about doing this in Craft CMS.
Try reading this.

return $this-&gt;render('index', ['twitterFeed' =&gt; $twitterFeed]); is correct in craft 3 you just need to do some custom routing in order to reroute the homepage to your controller/action.