CSS for home page only

I’m trying to queue a CSS file to only appear for the home page (which in this case is an exhibit page). I’ve added code to the end of the header.php stylesheets section as follows:

<!--CSS for home page only-->
<?php $url = $page->slug() ?>
<?php if $url == 'exhibits/show/home-page/home': ?>
    <?php queue_css_file('style_home_page.css'); ?>
<?php endif; ?>

This takes down the whole site so I suspect my php is broken. Can someone tell me how to do this?

Many thanks,
Sara

queue_css_file needs to be called before head_css() in header.php, so if you are adding it at the end of the file it won’t work. Also, it’s likely that a $page variable won’t always be present, which is probably what takes down the site.

So, at the top of header.php you might first check whether the $page variable is set before the other checks. Last, queue_css_file should not have the .css at the end, assuming that the file is in a usual css directory.

Cool, I’ll try incorporating those suggestions. Thanks so much for your help!