0

I got below error on my category pages and product pages after setting minify html to yes:

Parse error: syntax error, unexpected ‘<‘, expecting end of file” magento2 production mode

What should i do?

  • Can you please share the exact error message. Either some of your phtml files haven't generated properly in var/view_preprocessed – Raj Mohan R May 22 '19 at 11:58
1

The cause of such errors is hidden in the template files. In the following commented code

1 <?php //echo "this is an unwanted php code";?>

there is no space between the semicolon “;” and the closing tag of php i.e. “?>” which causes the error.

For the above code, when the HTML file is minified, the closing tag of php is considered as a part of the commented code which is not included in the minified file and throws the error.

So, while commenting a php code in a phtml file, make sure that there is a space before the closing tag of php as done in the code below-

1 <?php //echo "this is an unwanted php code"; ?>

Doing this will avoid the error due to minification of HTML file.

Hope this will help you.

| improve this answer | |
  • found it before and tried but not solved – MGPM May 23 '19 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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