diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php
new file mode 100644
index 0000000000000000000000000000000000000000..f22f265cc7bcfe021782605306d1a5b54187c9eb
--- /dev/null
+++ b/modules/saml/hooks/hook_metadata_hosted.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Hook to add the metadata for hosted entities to the frontpage.
+ *
+ * @param array &$metadataHosted  The metadata links for hosted metadata on the frontpage.
+ */
+function saml_hook_metadata_hosted(&$metadataHosted) {
+	assert('is_array($metadataHosted)');
+
+	$sources = SimpleSAML_Auth_Source::getSourcesOfType('saml:SP');
+
+	foreach ($sources as $source) {
+
+		$metadata = $source->getMetadata();
+
+		$name = $metadata->getValue('name', NULL);
+		if ($name === NULL) {
+			$name = $source->getAuthID();
+		}
+
+		$md = array(
+			'entityid' => $source->getEntityId(),
+			'metadata-index' => $source->getEntityId(),
+			'metadata-set' => 'saml20-sp-hosted',
+			'metadata-url' => $source->getMetadataURL() . '?output=xhtml',
+			'name' => $name,
+		);
+
+		$metadataHosted[] = $md;
+	}
+
+}