Skip to content

Instantly share code, notes, and snippets.

@davlgd
Created May 11, 2024 16:00
Show Gist options
  • Save davlgd/8c67b2350675561e9e442734eb03b44f to your computer and use it in GitHub Desktop.
Save davlgd/8c67b2350675561e9e442734eb03b44f to your computer and use it in GitHub Desktop.
IndexNow script to send batch of URL
#!/bin/bash
key="${INDEXNOW_KEY}"
domain=your.domain.com
url_array=()
url_list_json=$(printf ', "%s"' "${url_array[@]}")
url_list_json="[ ${url_list_json:2} ]"
json_body=$(cat <<EOF
{
"host": "${domain}",
"key": "$key",
"keyLocation": "https://${domain}/${key}.txt",
"urlList": $url_list_json
}
EOF
)
content_length=$(echo -n "$json_body" | wc -c)
curl -X POST -H "Content-Type: application/json" \
-H "Content-Length: $content_length" \
-d "$json_body" "https://api.indexnow.org/IndexNow" -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment