I'm editing an HTML file that also contains CSS and Javascript. I would like to keep this in an Org file with each in separate blocks like

CSS code ...

Javascript code ...

#+BEGIN_SRC html
html ...

so that when I edit the blocks with "C-c '" I can be in the proper mode. However the HTML block needs to include (substitute) the other 2 blocks verbatim, but Org wants to "evaluate" them, which doesn't make sense in this case. I haven't found a way to make a variable contain a whole named block literally and then be substituted. Is this possible?

1 Answer 1


You seem to want to use the literate capabilities of org mode, with noweb reference:

#+name: mycss
#+begin_src css
  This is css

#+name: myjs
#+begin_src js
  this is js

#+name: myhtlm
#+begin_src html :noweb yes
      <style type="text/css" media="screen">

<<mycss>> and <<myjs>> are noweb reference, that will be replaced by the content of the mycss and myjs source block

  • 1
    Thank you very much! I never quite understood how the noweb thing worked but this is probably what I want. But when I hit "C-c C-c" on the "#+begin_src html" line it says "org-babel-execute-src-block: No org-babel-execute function for html!". How do I make it create the output?
    – jtgd
    Apr 16, 2018 at 22:47
  • OK, poking around I discovered org-babel-expand-src-block which seems to expand correctly. I puts it in a temp buffer it creates, but I'm wondering if there are other ways to do this. Ultimately I will want this in a file which I upload to S3. Is there a way I can script this with elisp or possibly in some Org-style?
    – jtgd
    Apr 17, 2018 at 6:19
  • (org-babel-expand-noweb-references) seems to be what I was looking for. Once I get the point inside the block and call that it returns it as a string. Thanks again.
    – jtgd
    Apr 17, 2018 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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