diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.3.8.4
+
+-   [Fix] secLabels
+-   [ManData] Generate table of contents in embedded html; filter out kramdown toc marker
+-   [Docs] Add toc to gh-pages
+
 ## 0.3.8.3
 
 -   [Fix] Pandoc 2.11.0.1 fixes the issue fixed in the previous release upstream.
diff --git a/docs/index.md b/docs/index.md
--- a/docs/index.md
+++ b/docs/index.md
@@ -7,6 +7,9 @@
 pandoc-crossref is a pandoc filter for numbering figures, equations,
 tables and cross-references to them.
 
+* TOC
+{:toc}
+
 # Caveats
 
 ## LaTeX output and `--include-in-header`
diff --git a/lib/Text/Pandoc/CrossRef/References/Blocks.hs b/lib/Text/Pandoc/CrossRef/References/Blocks.hs
--- a/lib/Text/Pandoc/CrossRef/References/Blocks.hs
+++ b/lib/Text/Pandoc/CrossRef/References/Blocks.hs
@@ -78,11 +78,11 @@
     unless ("unnumbered" `elem` cls) $ do
       modify curChap $ \cc ->
         let ln = length cc
-            cl = lookup "label" attrs
-            inc l = init l <> [(fst (last l) + 1, cl)]
+            cl i = lookup "label" attrs <> customLabel opts "sec" i
+            inc l = let i = fst (last l) + 1 in init l <> [(i, cl i)]
             cc' | ln > n = inc $ take n cc
                 | ln == n = inc cc
-                | otherwise = cc <> take (n-ln-1) (zip [1,1..] $ repeat Nothing) <> [(1,cl)]
+                | otherwise = cc <> take (n-ln-1) (zip [1,1..] $ repeat Nothing) <> [(1,cl 1)]
         in cc'
       when ("sec:" `T.isPrefixOf` label') $ do
         index  <- get curChap
diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal
--- a/pandoc-crossref.cabal
+++ b/pandoc-crossref.cabal
@@ -4,10 +4,10 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 39f79bf240895e159f195d272e9604b08b795a6bce6ce663305b8aee2189ab82
+-- hash: e482ef1e6f935e9229bb87d11a279dd174efa3767a94b99a83941d6bd6cfad1e
 
 name:           pandoc-crossref
-version:        0.3.8.3
+version:        0.3.8.4
 synopsis:       Pandoc filter for cross-references
 description:    pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.
 category:       Text
@@ -55,6 +55,9 @@
     test/m2m/multiple-eqn-same-para/expect.md
     test/m2m/multiple-eqn-same-para/expect.tex
     test/m2m/multiple-eqn-same-para/input.md
+    test/m2m/secLabels/expect.md
+    test/m2m/secLabels/expect.tex
+    test/m2m/secLabels/input.md
     test/m2m/section-template/expect.md
     test/m2m/section-template/expect.tex
     test/m2m/section-template/input.md
diff --git a/src/ManData.hs b/src/ManData.hs
--- a/src/ManData.hs
+++ b/src/ManData.hs
@@ -23,6 +23,7 @@
 
 import Language.Haskell.TH.Syntax
 import qualified Data.Text as T
+import qualified Data.Text.IO as T
 import System.IO
 import qualified Text.Pandoc as P
 import Control.DeepSeq
@@ -32,18 +33,18 @@
 dataFile :: FilePath
 dataFile = "docs/index.md"
 
-readDataFile :: IO String
+readDataFile :: IO T.Text
 readDataFile =
   withFile dataFile ReadMode $ \h -> do
     hSetEncoding h utf8
-    cont <- hGetContents h
+    cont <- T.replace "* TOC\n{:toc}\n" "" <$> T.hGetContents h
     return $!! cont
 
 embedManual :: (P.Pandoc -> P.PandocPure T.Text) -> Q Exp
 embedManual fmt = do
   qAddDependentFile dataFile
   d <- runIO readDataFile
-  let pd = either (error . show) id $ P.runPure $ P.readMarkdown readerOpts (T.pack d)
+  let pd = either (error . show) id $ P.runPure $ P.readMarkdown readerOpts d
   let txt = either (error . show) id $ P.runPure $ fmt pd
   strToExp $ T.unpack txt
 
@@ -63,6 +64,8 @@
   embedManual $ P.writeHtml5String P.def{
     P.writerTemplate = Just tt
   , P.writerHighlightStyle = Just pygments
+  , P.writerTOCDepth = 6
+  , P.writerTableOfContents = True
   }
 
 strToExp :: String -> Q Exp
diff --git a/test/m2m/secLabels/expect.md b/test/m2m/secLabels/expect.md
new file mode 100644
--- /dev/null
+++ b/test/m2m/secLabels/expect.md
@@ -0,0 +1,16 @@
+# a First Level Section {#first-level-section}
+
+## a.a Second Level Section {#second-level-section}
+
+![Figure a: my figure](myfig.png){#fig:myfig}
+
+## a.b Other Second Level Section {#other-second-level-section}
+
+::: {#tbl:mytable}
+  a   b   c
+  --- --- ---
+  1   2   3
+  4   5   6
+
+  : Table I: My table
+:::
diff --git a/test/m2m/secLabels/expect.tex b/test/m2m/secLabels/expect.tex
new file mode 100644
--- /dev/null
+++ b/test/m2m/secLabels/expect.tex
@@ -0,0 +1,33 @@
+\hypertarget{first-level-section}{%
+\section{a First Level Section}\label{first-level-section}}
+
+\hypertarget{second-level-section}{%
+\subsection{a.a Second Level Section}\label{second-level-section}}
+
+\begin{figure}
+\hypertarget{fig:myfig}{%
+\centering
+\includegraphics{myfig.png}
+\caption{my figure}\label{fig:myfig}
+}
+\end{figure}
+
+\hypertarget{other-second-level-section}{%
+\subsection{a.b Other Second Level
+Section}\label{other-second-level-section}}
+
+\hypertarget{tbl:mytable}{}
+\begin{longtable}[]{@{}lll@{}}
+\caption{\label{tbl:mytable}My table}\tabularnewline
+\toprule
+a & b & c\tabularnewline
+\midrule
+\endfirsthead
+\toprule
+a & b & c\tabularnewline
+\midrule
+\endhead
+1 & 2 & 3\tabularnewline
+4 & 5 & 6\tabularnewline
+\bottomrule
+\end{longtable}
diff --git a/test/m2m/secLabels/input.md b/test/m2m/secLabels/input.md
new file mode 100644
--- /dev/null
+++ b/test/m2m/secLabels/input.md
@@ -0,0 +1,22 @@
+---
+numberSections: true
+sectionsDepth: -1
+secLabels: alpha a
+figLabels: alpha a
+tblLabels: roman
+---
+
+# First Level Section
+
+## Second Level Section
+
+![my figure](myfig.png){#fig:myfig}
+
+## Other Second Level Section
+
+a   b   c
+--- --- ---
+1   2   3
+4   5   6
+
+: My table {#tbl:mytable}
diff --git a/test/m2m/section-template/expect.md b/test/m2m/section-template/expect.md
--- a/test/m2m/section-template/expect.md
+++ b/test/m2m/section-template/expect.md
@@ -1,8 +1,6 @@
-Chapter 1. First Level Section {#first-level-section}
-==============================
+# Chapter 1. First Level Section {#first-level-section}
 
-Section 1.1. Second Level Section {#second-level-section}
----------------------------------
+## Section 1.1. Second Level Section {#second-level-section}
 
 ### Paragraph 1.1.1. Thrid Level Section {#thrid-level-section}
 
