Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to build my site with Html5Boilerplate and for the most parts it's going as I whish. However, I'm still unable to get the CSS reference to update in my PHP file.

My folder structure is as follows:

    css/style.css
    page/header.php

Now in the header.php file I have:

    <!-- scripts concatenated and minified via ant build script-->
        <link rel='stylesheet' href='css/style.css'/>
    <!-- end scripts-->

I would expect the built header.php file to have the following:

    <link rel='stylesheet' href='css/a4cd4c0.css'/>

But unfortunately it is not updating the reference.

In the project.properties file I have: file.pages = page/* and it is stripping the comments in the header.php file, so I know the build script doesn't skip the file.

I have tried variaties, like:

    <!-- CSS concatenated and minified via ant build script-->
        <link rel='stylesheet/css' type='text/css' href='css/style.css'/>
    <!-- end CSS-->

But this hasn't done a thing either . . .

Is there anyone who has tried to update their CSS files with Html5Boilerplate in their PHP files? What could I try to get the reference to be updated by the build script? And my last question is: Could I let the build script update the reference, if I use the following line for including my CSS?

    <link rel='stylesheet/css' type='text/css' href='<?PHP echo(CSS_PATH) ?>style.css'/>

EDIT: By fiddling around in the build.xml file, I have not only got it working, but also with my php echo. Around line 623 of the build.xml file I have changed the lines:

    <replaceregexp match="&lt;link rel=['&quot;]?stylesheet['&quot;]?\s+href=['&quot;]?(.*)/${file.root.stylesheet}(?:\?.*)?['&quot;]?\s*&gt;" 
        replace="&lt;link rel='stylesheet' href='\1/${css.sha}.css'&gt;" flags="m">

to

    <replaceregexp match="href=['&quot;]?(.*\?&gt;)${file.root.stylesheet}(?:\?.*)?['&quot;]?" 
        replace="href='\1${css.sha}.css'" flags="m">

Hopefully this helps someone who is running to a similiar problem.

share|improve this question

1 Answer 1

Depending on the version of HTML5Boilerplate you are using, the answer most probably lies in removing the comments in the .htaccess file specifically regarding 'Built-in filename-based cache busting'.

Here is the code section from HTML5 Boilerplate 4.1.

`<IfModule mod_rewrite.c>
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
 </IfModule>`

It would be inadvisable to edit or rework the build.xml file;

  • It is far more efficient to edit the .htaccess file.
  • You increase risk of not being able to future proof your application with updates and releases to HTML5 Boilerplate.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.