Index in KOMA-Script layers
The page style is used during the output routine and there \index
is redefined to do nothing. You can try to write the index entry with low level commands, but then you don't get links from hyperref. You could also move the index code to the onselect
-hook of the page style. But as pagestyles can be selected in various places without being used at the end you could end with too many index entries. The onevenpage
-option looks more logical but doesn't work.
\RequirePackage{luatex85}
\documentclass[paper=a4,twoside]{scrbook}
\makeatletter
\usepackage{fontspec,polyglossia}
\setdefaultlanguage[variant=usmax]{english}
\usepackage{hyperref}
\usepackage{makeidx}
\usepackage{scrlayer,scrlayer-scrpage}
\makeatletter
\DeclareNewLayer[
foreground,
align=l,
area={.25\paperwidth}{.37\paperheight}{.5\paperwidth}{.5\paperheight},
contents={some content with an index entry without link:
\protected@write\@indexfile{}%
{\string\indexentry{index entry in content}{\thepage}}},
]{intentionallyBlankLayer}
\DeclareNewPageStyleByLayers[
onselect =
{\ifnumodd{\value{page}}{}{\index{index quote in onselect}}}]{intentionallyBlank}{intentionallyBlankLayer}
\KOMAoptions{cleardoublepage=intentionallyBlank}
\makeindex
\begin{document}
\chapter{Lorem foo}
Some text with a working index\index{index does work here A}.
\chapter{Lorem bar}
Some other text with a working index\index{index does work here B}.
\printindex
\end{document}