In our email we have multiple content blocks and I am trying to call the content block within a cloud page using a simple AMPscript code something like below

  <!DOCTYPE html>
<html lang="en">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">

 %%= TreatAsContent(ContentBlockByKey("CONTENT_BLOCK_KEY")) =%%


But I get an error page with status code 500

Could anyone tell me how to call a content block using AMPscript in a CloudPage? or any other way to resolve this easily?

  • Remove the spaces and try %%=TreatAsContent(ContentBlockByKey("CONTENT_BLOCK_KEY"))=%% Commented Apr 19, 2022 at 11:26
  • That worked, thank you so much..
    – vorak
    Commented Apr 19, 2022 at 11:33
  • what is the issue with spaces in cloudpage? But same code with spaces works in email
    – vorak
    Commented Apr 19, 2022 at 11:36
  • 1
    @JonasLamberty : You should add that as an answer (which hopefully the OP will select). That would be much better for future seekers/readers.
    – Moonpie
    Commented Apr 19, 2022 at 11:52

1 Answer 1


Remove the spaces and try


As to why your code works in emails, good question. I've never tried this pattern with spaces, but they are definitely superfluous at best.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .