def add_index(self, context):
		# table of contents

		extn = ""
		if context.page_links_with_extn:
			extn = ".html"

		if "{index}" in context.main_section and context.get("children") and len(context.children):
			full_index = get_full_index(context.pathname, extn = extn)

			if full_index:
				html = frappe.get_template("templates/includes/full_index.html").render({
					"full_index": full_index,
					"url_prefix": context.url_prefix
				})

				context.main_section = context.main_section.replace("{index}", html)

		# next and previous
		if "{next}" in context.main_section:
			next_item = self.get_next()
			next_item.extn = "" if self.has_children(next_item.name) else extn
			if next_item and next_item.page_name:
				if context.relative_links:
					if next_item.next_parent:
						next_item.name = "../" + next_item.page_name or ""
					else:
						next_item.name = next_item.page_name or ""
				else:
					if next_item and next_item.name and next_item.name[0]!="/":
						next_item.name = "/" + next_item.name

				if not next_item.title:
					next_item.title = ""
				html = ('<p class="btn-next-wrapper">'+_("Next")\
					+': <a class="btn-next" href="{name}{extn}">{title}</a></p>').format(**next_item)
			else:
				html = ""

			context.main_section = context.main_section.replace("{next}", html)
Add index, next button if `{index}`, `{next}` is present.
dataset/ETHPy150Open frappe/frappe/frappe/website/doctype/web_page/web_page.py/WebPage.add_index