diff --git a/tetras_extraction/macao_12/script/src/export_corese.py b/tetras_extraction/macao_12/script/src/export_corese.py
index ac8292c8476c71ce5f415ff91030bb30595c5138..19f42d7f5b76b69193526bb53739a686148a2036 100644
--- a/tetras_extraction/macao_12/script/src/export_corese.py
+++ b/tetras_extraction/macao_12/script/src/export_corese.py
@@ -46,4 +46,5 @@ def apply_templates() -> str:
     # ==> Run STTL transformation
     tr = Transformer.create(graph, MODULE_DIR + "/../templates/")
     result = tr.transform()
+    print(result)
     return result
diff --git a/tetras_extraction/macao_12/script/templates/activite.rq b/tetras_extraction/macao_12/script/templates/activite.rq
index 781318af3656068fa4746acc376fb84444c919f0..c104b543a2c1ef6711e6b8d2a08c823b2aec0038 100644
--- a/tetras_extraction/macao_12/script/templates/activite.rq
+++ b/tetras_extraction/macao_12/script/templates/activite.rq
@@ -3,38 +3,37 @@ PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
 PREFIX st: <http://ns.inria.fr/sparql-template/>
 PREFIX owl: <http://www.w3.org/2002/07/owl#>
 
-# Entry point of the template set.
 # Generic Activity template that creates a Markdown page with Hugo front-matter,
 # and calls other specific templates when necessary
-template {
-    "####### " st:call-template(mt:path, ?subj)
-    format {
-        """
-+++
-title = "%s"
-weight = %s0
-+++
+template mt:activite(?act) {
+    mt:start_marker(?act) "/index.md" st:nl()
+#     format {
+#         """
+# +++
+# title = "%s"
+# weight = %s0
+# +++
 
-%s
-"""
-        ?title
-        ?weight
-        ?desc
-    }
-    # Insert a Hugo shortcode to load the quiz if this is a quiz activity
-    if (exists { ?subj a :Exercice }, "\n{{< quiz >}}", "")
-    "%%%%%%%"
-    st:call-template(mt:quiz,?subj)
+# %s
+# """
+#         ?title
+#         ?weight
+#         ?desc
+#     }
+#     # Insert a Hugo shortcode to load the quiz if this is a quiz activity
+#     if (exists { ?act a :Exercice }, "\n{{< quiz >}}", "")
+#     "%%%%%%%"
+#     st:call-template(mt:quiz,?act)
 }
 where {
-    ?subj a :Activite .
-    ?subj :id ?id .
-    ?subj :titre ?title .
-    ?subj :description ?desc .
+    ?act a :Activite .
+    ?act :id ?id .
+    ?act :titre ?title .
+    ?act :description ?desc .
     optional {
         # Turn the page index into a Hugo weight: increment and add a zero, to
         # leave room for adding new pages in-between later
-        ?subj :index ?index .
+        ?act :index ?index .
         bind(?index + 1 as ?weight)
     }
 }
diff --git a/tetras_extraction/macao_12/script/templates/functions.rq b/tetras_extraction/macao_12/script/templates/functions.rq
index dce99d75ed37a1981e33b017fa83d5e3b7ce5a8c..7c3ce17e7f44047db66b74f0a435d54e0d03ff81 100644
--- a/tetras_extraction/macao_12/script/templates/functions.rq
+++ b/tetras_extraction/macao_12/script/templates/functions.rq
@@ -16,16 +16,25 @@ function st:process(?x) {
         # st:format("%s", ?x),
         substr(?x, 0 , 40), 
         if (isURI(?x),
-            replace(?x, :, ":"),
+            # Explicitly show when no template was found for a URI by printing
+            # it with a "default" marker
+            st:format("[default %s]", replace(?x, :, ":")),
             st:turtle(?x)
         )
     )
 }
 
+# Generates the marker that indicates the start of a new file to create.
+# The marker begins with a constant distinctive string, then the node's path
+# built with the mt:path template.
+function mt:start_marker(?node) {
+    concat("####### ", st:call-template(mt:path, ?node))
+}
+
 # JSON lines often end with a comma, and st:nl() is a newline
 # with the current indent level (see the docs).
 function mt:sep() {
-    st:format(",%s", st:nl())
+    concat(",", st:nl())
 }
 
 # Escape illegal characters for JSON strings
diff --git a/tetras_extraction/macao_12/script/templates/module.rq b/tetras_extraction/macao_12/script/templates/module.rq
new file mode 100644
index 0000000000000000000000000000000000000000..2b656c5df8bff4448dadb929c046161488890386
--- /dev/null
+++ b/tetras_extraction/macao_12/script/templates/module.rq
@@ -0,0 +1,24 @@
+PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
+PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
+PREFIX st: <http://ns.inria.fr/sparql-template/>
+
+template mt:module(?mod) {
+    mt:start_marker(?mod) "/_index.md" st:nl()
+    
+    group {
+        st:call-template(mt:module, ?child) ; separator=''
+    }
+    group {
+        st:call-template(mt:activite, ?child_act) ; separator=''
+    }
+} where {
+    { ?mod a :Module } union { ?mod a :SousPartie } .
+    ?mod :titre ?title .
+    
+    optional {
+        { ?mod :contientModule ?child } union { ?mod :contientSousPartie ?child }
+    }
+    optional {
+        ?mod :contientActivite ?child_act
+    }
+}
diff --git a/tetras_extraction/macao_12/script/templates/start.rq b/tetras_extraction/macao_12/script/templates/start.rq
new file mode 100644
index 0000000000000000000000000000000000000000..e623679af547a80faeac21a1e50c40983db51c64
--- /dev/null
+++ b/tetras_extraction/macao_12/script/templates/start.rq
@@ -0,0 +1,14 @@
+PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
+PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
+PREFIX st: <http://ns.inria.fr/sparql-template/>
+
+# Entry point of the template set.
+# Begins with the top-level modules
+template st:start {
+  st:call-template(mt:module, ?top_module)
+}
+where {
+  ?top_module a :Module .
+  # Top level <=> not contained in another module
+  FILTER NOT EXISTS { ?mod :contientModule ?top_module }
+}
\ No newline at end of file