def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
file.write(template)
file.write('\n') # Use single quotes here
for article in articles_info:
file.write(
f' \n'
f' <a href="{article["filepath"]}">\n'
f' <img class="rounded-t-lg" src="{article["thumbnail"]}" alt="{article["title"]}"/>\n'
f' \n'
f' \n'
f' \n'
f' {article["title"]}\n'
f' \n'
f' \n'
f' {article["description"]}\n'
f' \n'
f' \n'
f' \n'
)
file.write('\n')
Membaca file JSON untuk mendapatkan informasi artikel
with open(filename_json, "r") as file_json:
list_file_html = json.load(file_json)
Membuat informasi artikel dari nama file untuk kemudian digenerate menjadi HTML kartu
articles_info = [{"filepath": filename, "title": "Judul Artikel", "thumbnail": "URL Thumbnail", "description": "Deskripsi singkat"} for filename in list_file_html]
Membuat string HTML untuk template header yang akan disimpan di indeks file
html_template_header = "\n"
Membuat indeks HTML dengan informasi artikel yang telah dihasilkan
print("Indeks artikel HTML telah berhasil dibuat.") buat ful html dan ada FULL seo di dalam nya
Assistant
To create a full HTML page with basic SEO elements and the card layout generated by the given create_index_html function, we need to:
Start by setting up a basic HTML5 structure.
Include meta tags for SEO.
Use the given create_index_html function to inject our articles into the right place.
In terms of SEO, we will include:
A charset declaration
A viewport meta tag for responsive design
The title tag
Meta description for the page
Meta tags for Open Graph (for social media websites)
Meta tags for Twitter cards
This is an example of how you would combine all of these elements:
python
User
def create_full_html(template, articles_info, output_file=“indeks_artikel.html”):
full_html = (
‘\n’
‘\n’
‘\n’
’ \n’
’ <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>\n’
’ <meta name=“description” content=“A collection of articles”>\n’
’ <meta property=“og:title” content=“Article Index” />\n’
’ \n’
’ <meta property=“og:description” content=“A compilation of interesting articles” />\n’
’ <meta property=“og:image” content=“URL to an image representing the content of the page” />\n’
’ \n’
’ <meta name=“twitter:title” content=“Article Index”>\n’
’ <meta name=“twitter:description” content=“A compilation of interesting articles”>\n’
’ <meta name=“twitter:image” content=“URL to an image representing the content of the page”>\n’
’ Article Index\n’
# Add any other SEO tags or links to stylesheets here
‘\n’
‘\n’
f’{template}\n’
# Your existing div class for articles will go here
‘\n’
‘’
)
code
with open(output_file, “w”) as file:
file.write(full_html)
file.write(‘<div class="grid-cols-1 sm:grid md:grid-cols-3 ">\n’)
for article in articles_info:
file.write(
# … (rest of the article card template you originally provided)
)
file.write(‘</div>\n’)
Assuming filename_json contains the path to your JSON file with article data
filename_json = “path_to_your_json_file.json”
with open(filename_json, “r”) as file_json:
list_file_html = json.load(file_json)
articles_info = [{“filepath”: filename, “title”: “Judul Artikel”, “thumbnail”: “URL Thumbnail”, “description”: “Deskripsi singkat”} for filename in list_file_html]
The template header provided is already part of the create_full_html function
html_template_header = (
“\n”
“\n”
" \n"
“\n”
# … (any additional content before the article cards)
)
Create the index HTML with the article information
print(“Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.”) buat kan full nya
Assistant
It seems you have a syntax issue with the quotation marks you're using (“ and ”). In Python, you should use straight quotation marks (either single ' or double "). Additionally, the create_full_html function currently writes only the template and the outer div tags to the output file. You'll need to include the actual content creation part that was in your original create_index_html function.
Also, you only need to work with the create_full_html function since it's intended to replace the create_index_html function. Below is the corrected and complete code, assuming that you have a basic understanding of HTML, CSS, and Python:
python
User
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
file.write(template)
file.write('\n') # Use single quotes here
for article in articles_info:
file.write(
f' \n'
f' <a href="{article["filepath"]}">\n'
f' <img class="rounded-t-lg" src="{article["thumbnail"]}" alt="{article["title"]}"/>\n'
f' \n'
f' \n'
f' \n'
f' {article["title"]}\n'
f' \n'
f' \n'
f' {article["description"]}\n'
f' \n'
f' \n'
f' \n'
)
file.write('\n')
Membaca file JSON untuk mendapatkan informasi artikel
with open(filename_json, "r") as file_json:
list_file_html = json.load(file_json)
Membuat informasi artikel dari nama file untuk kemudian digenerate menjadi HTML kartu
articles_info = [{"filepath": filename, "title": "Judul Artikel", "thumbnail": "URL Thumbnail", "description": "Deskripsi singkat"} for filename in list_file_html]
Membuat string HTML untuk template header yang akan disimpan di indeks file
html_template_header = "\n"
Membuat indeks HTML dengan informasi artikel yang telah dihasilkan
print("Indeks artikel HTML telah berhasil dibuat.")
masukan di sini
Assistant
I can see that you've prepared a Python function called create_index_html, which takes in a template string, a list of article information dictionaries, and optionally a file name for output (with a default value of "indeks_artikel.html"). You then intend to read article data from a JSON file and generate an HTML file that lists articles in a card format.
Below is the entire process covering how to read from the JSON file and create a full HTML file for an article index, including the SEO basics. Please make sure to replace filename_json with the actual path to your JSON file, and fill in the JSON structure with the properties matching the keys used in articles_info (e.g., "filepath", "title", "thumbnail", "description").
python
User
for article in articles_info:
# Each article card
file.write(' <div class="mx-3 mt-6 flex flex-col …\n') # Truncated for brevity
# … The rest of the article card HTML
file.write(' \n')
code
file.write('</div>\n') # Close the article cards container
file.write('</div>\n') # Close the primary container
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>') buat full nya
Assistant
Certainly! It seems you want the full HTML structure for the article cards, so I'll go ahead and expand the truncated section of the loop where the article cards are written to the file. Below is the complete function that creates the full HTML document including the article cards:
python
User
import os
import json
from datetime import datetime
import random
Variabel untuk menyimpan daftar file HTML
list_file_html = []
Fungsi untuk mendapatkan tanggal pembuatan artikel
Fungsi untuk menghasilkan prediksi togel secara acak dari BBFS
def generate_random_predictions():
# Generate BBFS (7 unique random digits)
bbfs = [str(random.randint(0, 9)) for _ in range(7)]
random.shuffle(bbfs) # Shuffle the digits to add more randomness
bbfs_str = "".join(bbfs)
code
# Pick random elements from BBFS to create other elements
am = random.sample(bbfs, k=5)
digits = ["".join(random.sample(bbfs, k=4)) for _ in range(4)]
two_digits_bb = ["".join(random.sample(bbfs, k=2)) for _ in range(10)]
colok_bebas = random.sample(bbfs, k=3)
twin = [num * 2 for num in random.sample(bbfs, k=4)]
# Shio based on random choice of animals
# Note: Shio doesn"t need to derive from BBFS
shio = random.sample(["Tikus", "Kerbau", "Macan", "Kelinci", "Naga", "Ular", "Kuda", "Kambing", "Monyet", "Ayam", "Anjing", "Babi"], k=3)
return {
"BBFS": bbfs_str,
"AM": "".join(am),
"4D TOP": digits,
"2D TOP BB": two_digits_bb,
"COLOK BEBAS": colok_bebas,
"TWIN": twin,
"SHIO": shio
}
Fungsi untuk membuat struktur HTML dari artikel dengan elemen-elemen SEO dan tabel prediksi
def buat_html_artikel(tanggal, prediksi):
judul = f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal}"
deskripsi = "Prediksi Togel Hongkong terbaru dan terjitu. Dapatkan bocoran angka, shio, dan prediksi lainnya untuk meningkatkan peluang kemenangan Anda."
keywords = "prediksi togel, prediksi hongkong, togel hongkong, prediksi togel terjitu, prediksi togel terpercaya"
code
# Membuat struktur HTML dengan elemen-elemen SEO dan tabel prediksi
html_artikel = f"""
code
Assistant
It seems you have a complete working script that generates article HTML from predictions, saves it to a file, adds the filename to a JSON list, and finally creates an index HTML file that lists all articles.
However, there's a small issue with how the articles are added to articles_info from the JSON data. The structure you have seems to suggest that the JSON data is just a list of filenames, not dictionaries. Therefore, using .get on each article when appending to articles_info might not be correct.
Here's how to fix this and produce the proper index HTML file with information about each article:
python
User
Assistant
If you're asking for an example of how to create a header section for an HTML document using Tailwind CSS (referred to as TW Elements in your comment), here's a simple template you might use. Please note that you need to customize it according to your requirements, such as adding navigation links, branding, etc.
A responsive navigation bar with a container to center the content.
A branding or logo area that can be an anchor tag linking to the home page.
A series of navigation links that should be updated to reflect the structure of your site.
Make sure that Tailwind CSS is included via CDN in this example, or you could install it as part of your build process. The version mentioned here is 2.x; check for the latest version if necessary and update the URL accordingly. Additionally, the classes used for styling the header follow Tailwind CSS conventions and may need to be adjusted based on the version of Tailwind you're using or your project's design requirements.
The IndentationError: unexpected indent you're seeing indicates that there is an issue with the whitespace at the beginning of the line in your Python script. In Python, indentation is used to denote blocks of code, and all lines within the same block must be indented the same amount.
Here is how you should correct your code:
python
# Open the file with write mode
with open("filename.html", "w") as file:
# Write other HTML and content here before the script tag
# Write the Tailwind CSS script tag
file.write('<script src="https://cdn.tailwindcss.com"></script>\n') # Ensure proper indentation
# Write more content or closing tags if necessary
Make sure that:
You are using consistent indentation throughout your Python file, typically 4 spaces per indentation level.
You do not mix tabs and spaces for indentation within the same file – stick to one style (PEP 8 recommends spaces).
You are using standard straight quotation marks ("") in your Python code and not curly quotes (“”).
The code above should resolve the indentation error, provided that it is consistently indented with the rest of your file. If other parts of your script have different indentation (such as tabs or a different number of spaces), adjust the example to match your code's indentation style.
User
import os
import json
from datetime import datetime
import random
Variabel untuk menyimpan daftar file HTML
list_file_html = []
Fungsi untuk mendapatkan tanggal pembuatan artikel
Fungsi untuk menghasilkan prediksi togel secara acak dari BBFS
def generate_random_predictions():
# Generate BBFS (7 unique random digits)
bbfs = [str(random.randint(0, 9)) for _ in range(7)]
random.shuffle(bbfs) # Shuffle the digits to add more randomness
bbfs_str = "".join(bbfs)
code
# Pick random elements from BBFS to create other elements
am = random.sample(bbfs, k=5)
digits = ["".join(random.sample(bbfs, k=4)) for _ in range(4)]
two_digits_bb = ["".join(random.sample(bbfs, k=2)) for _ in range(10)]
colok_bebas = random.sample(bbfs, k=3)
twin = [num * 2 for num in random.sample(bbfs, k=4)]
# Shio based on random choice of animals
# Note: Shio doesn"t need to derive from BBFS
shio = random.sample(["Tikus", "Kerbau", "Macan", "Kelinci", "Naga", "Ular", "Kuda", "Kambing", "Monyet", "Ayam", "Anjing", "Babi"], k=3)
return {
"BBFS": bbfs_str,
"AM": "".join(am),
"4D TOP": digits,
"2D TOP BB": two_digits_bb,
"COLOK BEBAS": colok_bebas,
"TWIN": twin,
"SHIO": shio
}
Fungsi untuk membuat struktur HTML dari artikel dengan elemen-elemen SEO dan tabel prediksi
def buat_html_artikel(tanggal, prediksi):
judul = f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal}"
deskripsi = "Prediksi Togel Hongkong terbaru dan terjitu. Dapatkan bocoran angka, shio, dan prediksi lainnya untuk meningkatkan peluang kemenangan Anda."
keywords = "prediksi togel, prediksi hongkong, togel hongkong, prediksi togel terjitu, prediksi togel terpercaya"
code
# Membuat struktur HTML dengan elemen-elemen SEO dan tabel prediksi
html_artikel = f"""
code
Assistant
From your script, it looks like you've implemented a system where you generate HTML articles with prediction information, save them to individual HTML files, add these filenames to a JSON list, and then create an index HTML file to list all those articles. I'll provide you with a way to make sure that each article is linked from the index page so that they are interconnected.
Firstly, you need to be sure that the articles_info object passed to create_index_html contains all necessary information about each article, not just the filepath. Assuming each article's data (title, thumbnail, and description) is saved correctly, the create_index_html method should use this data to create links to each article with contextual information.
I'm including the corrected code snippet for the create_index_html function that assumes each item in articles_data is a dictionary with the relevant keys:
python
User
buat Lebih cantik tampilan nya dan tuliskan full nya
Assistant
Let's enhance the appearance of the index and article pages with a more elegant design using Tailwind CSS. Here's how you can update your Python code to create a professional-looking and interconnected index and article pages.
First, I'll refactor the code to produce complete HTML files with a neater presentation. The key changes include the usage of Tailwind CSS classes for improved styling and component layout. We'll create the header, articles, and footer components with a cleaner design.
Note: Before adopting the code snippets, ensure that Tailwind CSS classes used are compatible with the Tailwind CSS version you're using.
Here's the refactored and extended code that includes the full implementation:
python
User
buatkan FULL NYA
Assistant
Sure, I will now provide you with a complete example script to generate interlinked article and index HTML pages with Tailwind CSS for better styling. This script will:
Generate individual article pages with random predictions.
Create an index page that lists all article pages with links.
Use a consistent header and footer across all pages for better navigation and aesthetics.
In this script, we're using hard-coded thumbnail paths and descriptions. In a real-world scenario, these would likely come from your data source or content management system.
Please ensure that the output directory exists within your project directory before running this script.
python
User
Traceback (most recent call last):
File "C:\xampp\htdocs\coba\artikel\artikell.py", line 100, in
article_info = generate_complete_article(tanggal_pembuatan, prediksi_acak)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\xampp\htdocs\coba\artikel\artikell.py", line 89, in generate_complete_article
file.write(article_html)
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 1084: illegal multibyte sequence
To fix this, you must specify the encoding when opening the file for writing. Here's the updated generate_complete_article function that specifies UTF-8 encoding:
python
def generate_complete_article(tanggal, predictions):
predictions.update(description="Deskripsi singkat artikel di sini.") # Add a description to your predictions
article_html = buat_html_artikel(tanggal, predictions)
filename_html = f"prediksi_togel_hongkong_{tanggal}.html"
filepath_html = os.path.join(output_folder, filename_html)
with open(filepath_html, "w", encoding='utf-8') as file: # Specify encoding here
file.write(article_html)
return {
"filepath": filename_html,
"title": f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal}",
"thumbnail": "https://via.placeholder.com/150", # Placeholder image URL
"description": predictions["description"]
}
And a similar change to create_index_html:
python
def create_index_html(articles_info, output_file="index.html"):
with open(os.path.join(output_folder, output_file), "w", encoding='utf-8') as file: # Specify encoding here
# ... The rest of the function remains the same
Make sure to specify the encoding as utf-8 when opening files for writing anywhere in your script. That should fix the UnicodeEncodeError. Now when you write files, they'll explicitly use UTF-8 encoding, which can represent all Unicode characters.
User
code
Assistant
Adding SEO to your HTML page involves including various meta tags and structured data that help search engines understand the content of your page. Let's add a standard set of meta tags for SEO, Open Graph protocol, and Twitter Cards to improve the SEO of your article page.
Here's how your HTML <head> section could look after adding these tags:
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Primary Meta Tags -->
<title>Bocoran Prediksi Togel Hongkong Hari Ini 01-02-2024</title>
<meta name="title" content="Bocoran Prediksi Togel Hongkong Hari Ini 01-02-2024">
<meta name="description" content="Prediksi Togel Hongkong terbaru dan terjitu untuk tanggal 01-02-2024. Temukan prediksi terbaik untuk meningkatkan peluang kemenangan Anda.">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="article">
<meta property="og:url" content="http://example.com/path/to/article">
<meta property="og:title" content="Bocoran Prediksi Togel Hongkong Hari Ini 01-02-2024">
<meta property="og:description" content="Prediksi Togel Hongkong terbaru dan terjitu untuk tanggal 01-02-2024. Temukan prediksi terbaik untuk meningkatkan peluang kemenangan Anda.">
<meta property="og:image" content="http://example.com/path/to/image.jpg">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="http://example.com/path/to/article">
<meta property="twitter:title" content="Bocoran Prediksi Togel Hongkong Hari Ini 01-02-2024">
<meta property="twitter:description" content="Prediksi Togel Hongkong terbaru dan terjitu untuk tanggal 01-02-2024. Temukan prediksi terbaik untuk meningkatkan peluang kemenangan Anda.">
<meta property="twitter:image" content="http://example.com/path/to/image.jpg">
<!-- Canonical Link -->
<link rel="canonical" href="http://example.com/path/to/article">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.x/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100 text-gray-900 font-sans leading-normal tracking-normal">
<!-- ... Rest of the body content ... -->
User
def buat_html_artikel(tanggal, prediksi):
judul = f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal}"
code
html_artikel = f"""<!DOCTYPE html>
code
Assistant
Certainly! The function can be modified to include more comprehensive SEO tags, including Open Graph and Twitter Cards, as discussed previously.
Here's how you would modify the buat_html_artikel function to include these additional SEO enhancements:
python
def buat_html_artikel(tanggal, prediksi):
judul = f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal}"
deskripsi = "Prediksi Togel Hongkong terbaru dan terjitu. Dapatkan bocoran angka, shio, dan prediksi lainnya untuk meningkatkan peluang kemenangan Anda."
gambar = "URL_TO_IMAGE" # Replace with the actual URL to the image
url_artikel = "URL_TO_ARTICLE" # Replace with the actual URL to the article
html_artikel = f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SEO Meta Tags -->
<meta name="description" content="{deskripsi}">
<meta name="keywords" content="Prediksi Togel, Togel Hongkong, Prediksi Hari Ini">
<link rel="canonical" href="{url_artikel}">
<!-- Open Graph / Facebook Meta Tags -->
<meta property="og:type" content="website">
<meta property="og:url" content="{url_artikel}">
<meta property="og:title" content="{judul}">
<meta property="og:description" content="{deskripsi}">
<meta property="og:image" content="{gambar}">
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="example.com">
<meta property="twitter:url" content="{url_artikel}">
<meta name="twitter:title" content="{judul}">
<meta name="twitter:description" content="{deskripsi}">
<meta name="twitter:image" content="{gambar}">
<!-- Title Tag -->
<title>{judul}</title>
<!-- Tailwind CSS -->
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.x/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100 text-gray-900 font-sans leading-normal tracking-normal">
<!-- Article and Forecast Table Here -->
<!-- ... -->
{create_footer()}
<script src="https://cdn.tailwindcss.com"></script>
</body>
</html>
"""
return html_artikel
import json
def create_full_html(template, articles_info, output_file="indeks_artikel.html"):
full_html = (
'<!DOCTYPE html>\n'
'<html lang="en">\n'
'<head>\n'
' <meta charset="UTF-8">\n'
' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n'
' <meta name="description" content="A collection of articles">\n'
' <meta property="og:title" content="Article Index" />\n'
' <meta property="og:type" content="website" />\n'
' <meta property="og:description" content="A compilation of interesting articles" />\n'
' <meta property="og:image" content="URL to an image representing the content of the page" />\n'
' <meta name="twitter:card" content="summary_large_image">\n'
' <meta name="twitter:title" content="Article Index">\n'
' <meta name="twitter:description" content="A compilation of interesting articles">\n'
' <meta name="twitter:image" content="URL to an image representing the content of the page">\n'
' <title>Article Index</title>\n'
# Add any other SEO tags or links to stylesheets here
'</head>\n'
'<body>\n'
f'{template}\n'
# Your existing div class for articles will go here
'</body>\n'
'</html>'
)
with open(output_file, "w") as file:
file.write(full_html)
file.write('<div class="grid-cols-1 sm:grid md:grid-cols-3 ">\n')
for article in articles_info:
file.write(
# ... (rest of the article card template you originally provided)
)
file.write('</div>\n')
# Assuming filename_json contains the path to your JSON file with article data
filename_json = "path_to_your_json_file.json"
with open(filename_json, "r") as file_json:
list_file_html = json.load(file_json)
articles_info = [{"filepath": filename, "title": "Judul Artikel", "thumbnail": "URL Thumbnail", "description": "Deskripsi singkat"} for filename in list_file_html]
# The template header provided is already part of the create_full_html function
html_template_header = (
"<!-- Header content -->\n"
"<header>\n"
" <!-- Add header elements such as navigation links, logo, etc. -->\n"
"</header>\n"
# ... (any additional content before the article cards)
)
# Create the index HTML with the article information
create_full_html(html_template_header, articles_info)
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.")
Remember to replace the placeholders ("URL to an image representing the content of the page", path_to_your_json_file.json) with actual values that are relevant to your content and project. The code above is structured but does not include all of the article content you provided; you will need to insert that code within the comment # ... (rest of the article card template you originally provided).
import json
def create_full_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# Writing the initial part of the HTML document
file.write(
'<!DOCTYPE html>\n'
'<html lang="en">\n'
'<head>\n'
' <meta charset="UTF-8">\n'
' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n'
' <meta name="description" content="A collection of articles">\n'
' <meta property="og:title" content="Article Index" />\n'
' <meta property="og:type" content="website" />\n'
' <meta property="og:description" content="A compilation of interesting articles" />\n'
' <meta property="og:image" content="URL to an image representing the content of the page" />\n'
' <meta name="twitter:card" content="summary_large_image">\n'
' <meta name="twitter:title" content="Article Index">\n'
' <meta name="twitter:description" content="A compilation of interesting articles">\n'
' <meta name="twitter:image" content="URL to an image representing the content of the page">\n'
' <title>Article Index</title>\n'
# Add any other SEO tags or links to stylesheets here
'</head>\n'
'<body>\n'
f'{template}\n'
)
# Writing the articles section
file.write('<div class="grid-cols-1 sm:grid md:grid-cols-3">\n')
for article in articles_info:
file.write(
f' <div class="mx-3 mt-6 flex flex-col rounded-lg bg-white '
f'shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] '
f'dark:bg-neutral-700 sm:shrink-0 sm:grow sm:basis-0">\n'
f' <a href="{article["filepath"]}">\n'
f' <img class="rounded-t-lg" src="{article["thumbnail"]}" alt="{article["title"]}"/>\n'
f' </a>\n'
f' <div class="p-6">\n'
f' <h5 class="mb-2 text-xl font-medium leading-tight text-neutral-800 dark:text-neutral-50">\n'
f' {article["title"]}\n'
f' </h5>\n'
f' <p class="mb-4 text-base text-neutral-600 dark:text-neutral-200">\n'
f' {article["description"]}\n'
f' </p>\n'
f' </div>\n'
f' </div>\n'
)
file.write('</div>\n') # Close the articles div
# Write the closing tags for body and html
file.write('</body>\n</html>')
# Assuming filename_json contains the path to your JSON file with article data
filename_json = "path_to_your_json_file.json"
with open(filename_json, "r") as file_json:
list_file_html = json.load(file_json)
articles_info = [{"filepath": filename, "title": "Judul Artikel", "thumbnail": "URL Thumbnail", "description": "Deskripsi singkat"} for filename in list_file_html]
html_template_header = (
'<!-- Header content -->\n'
'<header>\n'
' <!-- Add header elements such as navigation links, logo, etc. -->\n'
'</header>\n'
# ... (any additional content before the article cards)
)
# Create the index HTML with the article information
create_full_html(html_template_header, articles_info)
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.")
Please note:
Replace path_to_your_json_file.json with the actual path to your JSON file.
Update the placeholders within meta properties (URL to an image representing the content of the page) with actual content.
Ensure you're serving this HTML in a web environment where relative paths to resources like images and CSS files are correctly set up.
Style and tweak your HTML/CSS as necessary to fit the design requirements of your project.
import json
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# HTML boilerplate
file.write('<!DOCTYPE html>\n')
file.write('<html lang="en">\n')
file.write('<head>\n')
file.write(' <meta charset="UTF-8">\n')
file.write(' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n')
file.write(' <meta http-equiv="X-UA-Compatible" content="ie=edge">\n')
file.write(' <meta name="description" content="A collection of articles">\n')
file.write(' <title>Your Website Title Here</title>\n')
# Add any other SEO tags or links to stylesheets here
file.write(template) # Adding the template header to the HTML file
file.write('</head>\n')
file.write('<body>\n')
# Article cards section
file.write('<div class="container">\n')
file.write('<div class="grid-cols-1 sm:grid md:grid-cols-3 ">\n')
for article in articles_info:
# Each article card
file.write(' <div class="mx-3 mt-6 flex flex-col ...\n') # Truncated for brevity
# ... The rest of the article card HTML
file.write(' </div>\n')
file.write('</div>\n') # Close the article cards container
file.write('</div>\n') # Close the primary container
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>')
# Assuming you have a JSON file with article data saved at `filename_json`
filename_json = "path_to_your_json_file.json"
with open(filename_json, "r") as file_json:
articles_data = json.load(file_json)
# Create article information based on the JSON data
# You might need to adapt this part depending on the structure of your JSON
articles_info = [
{
"filepath": article.get('filepath', '#'),
"title": article.get('title', 'Title Unavailable'),
"thumbnail": article.get('thumbnail', 'default_thumbnail.png'),
"description": article.get('description', 'No description provided.')
}
for article in articles_data
]
# HTML header template, possibly including links to CSS files, etc.
html_template_header = (
"<!-- Header content -->\n"
"<!-- TW Elements license info, navigation bar, other header elements -->\n"
)
# Create the index HTML with the article information
create_index_html(html_template_header, articles_info)
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.")
Remember that actual implementation may vary based on your HTML/CSS design, the specific structure of your JSON file, and any additional SEO requirements you might have. This example is intended to get you started with a working script.
import json
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# HTML boilerplate and header
file.write('<!DOCTYPE html>\n')
file.write('<html lang="en">\n')
file.write('<head>\n')
file.write(' <meta charset="UTF-8">\n')
file.write(' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n')
file.write(' <meta http-equiv="X-UA-Compatible" content="ie=edge">\n')
file.write(' <meta name="description" content="A collection of articles">\n')
file.write(' <title>Your Website Title Here</title>\n')
# Add links to stylesheets, additional SEO tags, and any other head elements here
file.write(template)
file.write('</head>\n')
file.write('<body>\n')
# Main content container (possibly adjusting the class names depending on your CSS framework)
file.write('<div class="container mx-auto mt-10">\n')
file.write('<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">\n')
for article in articles_info:
# Each article card
file.write(f' <div class="mx-3 mt-6 flex flex-col rounded-lg bg-white shadow-lg">\n')
file.write(f' <a href="{article["filepath"]}">\n')
file.write(f' <img class="rounded-t-lg" src="{article["thumbnail"]}" alt="{article["title"]}">\n')
file.write(f' </a>\n')
file.write(f' <div class="p-6">\n')
file.write(f' <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{article["title"]}</h5>\n')
file.write(f' <p class="mb-3 font-normal text-gray-700 dark:text-gray-400">{article["description"]}</p>\n')
file.write(f' </div>\n')
file.write(f' </div>\n')
# Close the article cards container and the primary container
file.write('</div>\n')
file.write('</div>\n')
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>')
# Example JSON data structure
articles_data = [
{
"filepath": "article-1.html",
"title": "Article Title 1",
"thumbnail": "thumbnail-1.jpg",
"description": "A short description of the first article."
},
# Additional article dictionaries...
]
# Using the above data structure as an example
articles_info = [
{
"filepath": article['filepath'],
"title": article['title'],
"thumbnail": article['thumbnail'],
"description": article['description']
}
for article in articles_data
]
html_template_header = (
'<!-- Header content -->\n'
'<header>\n'
' <!-- Your navigation bar, site logo, etc. -->\n'
'</header>\n'
)
# Create the index HTML with the article information
create_index_html(html_template_header, articles_info)
print("Indeks artikel HTML telah berhasil dibuat.")
Please make sure to include your CSS stylesheet link in the <head> section to ensure that the styles are applied correctly to your HTML page. If you're using a CSS framework like Tailwind CSS, you'll need to include its CDN link or refer to your custom stylesheet that includes Tailwind's classes. Also, remember to use your actual JSON data and file paths.
<header class="max-w-xl mx-auto mt-10 text-center">
<h1 class="text-4xl font-bold">{judul}</h1>
<p class="mt-2 text-sm text-gray-600">{deskripsi}</p>
</header>
<main class="max-w-xl mx-auto my-10 bg-white p-8 rounded-lg shadow-md">
<article>
<section class="my-5">
<h2 class="text-2xl font-semibold">Permainan Togel Hongkong</h2>
<p class="mt-4">Permainan Togel Hongkong menjadi salah satu hiburan populer di Indonesia. Sukses memenangkan permainan ini membutuhkan prediksi yang akurat dan terpercaya. Prediksi kami yang jitu akan meningkatkan peluang kemenangan Anda dalam permainan Togel Hongkong.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Bocoran Prediksi Togel HKG-Hongkong Terjitu</h2>
<p class="mt-4">Dalam artikel ini, Kubet akan memberikan wawasan mengenai pentingnya prediksi togel yang akurat dan terpercaya. Kami memberikan bocoran angka yang disusun dengan strategi teruji, sumber terpercaya, dan kerja sama para ahli yang berpengalaman dalam prediksi togel.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Prediksi Hongkong Hari Ini</h2>
<p class="mt-4">Prediksi Hongkong akan diperbarui setiap hari sebelum pukul 22.00 WIB. Meskipun kami menggunakan sumber dan ahli yang terpercaya, prediksi ini hanya sebagai peluang kemenangan dan tidak dijamin pasti.</p>
<!-- Tabel Prediksi -->
<div class="overflow-x-auto mt-6">
<table class="min-w-full bg-gradient-to-r from-red-700 to-red-700 border border-red-700 divide-y divide-red-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Kategori </th>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Prediksi </th>
</tr>
</thead>
<tbody>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">BBFS (Bolak-Balik Full Set)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["BBFS"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">AM (Angka Main)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["AM"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">4D TOP</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["4D TOP"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">2D TOP BB</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["2D TOP BB"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">COLOK BEBAS</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["COLOK BEBAS"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> TWIN</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(map(str, prediksi["TWIN"]))}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> SHIO</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(prediksi["SHIO"])}</td>
</tr>
</tbody>
</table>
</div>
<p class="mt-6 italic">Prediksi digunakan dengan pertimbangan sumber-sumber terpercaya dan kerjasama dengan para ahli. Prediksi ini hanya sebagai peluang kemenangan.</p>
</section>
</article>
</main>
<footer class="max-w-xl mx-auto my-6 text-center">
<p class="text-sm">Terima kasih telah mempercayai kubet sebagai sumber prediksi togel Hongkong Anda. Kami harap prediksi kami membantu dalam memilih angka yang tepat. Selamat bermain dan semoga beruntung!</p>
<p class="text-gray-600 text-sm mt-2">kubet Indonesia</p>
</footer>
<!-- Tailwind UI -->
<script src="https://cdn.tailwindcss.com"></script>
Generate random predictions
prediksi_acak = generate_random_predictions()
Dapatkan tanggal pembuatan untuk judul artikel
tanggal_pembuatan = get_current_date()
Ganti hanya bagian tertentu dengan hasil dari generate_random_predictions()
filename_html = f"prediksi_togel_hongkong_{tanggal_pembuatan}.html"
with open(filename_html, "w") as file_html:
file_html.write(html_artikel)
Tambahkan file HTML yang baru dibuat ke dalam list_file_html
list_file_html.append(filename_html)
Simpan list file HTML ke dalam file JSON
filename_json = "list_file_html.json"
with open(filename_json, "w") as file_json:
json.dump(list_file_html, file_json)
print(f"Artikel berhasil disimpan dalam file {filename_html}")
print(f"List file HTML berhasil disimpan dalam file {filename_json}")
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# HTML boilerplate
file.write('\n')
file.write('\n')
file.write('\n')
file.write(' \n')
file.write(' \n')
file.write(' \n')
file.write(' \n')
file.write(' Your Website Title Here\n')
# Add any other SEO tags or links to stylesheets here
file.write(template) # Adding the template header to the HTML file
file.write('\n')
file.write('\n')
code
# Article cards section
file.write('<div class="container">\n')
file.write('<div class="grid-cols-1 sm:grid md:grid-cols-3 ">\n')
for article in articles_info:
# Each article card
file.write(' <div class="mx-3 mt-6 flex flex-col …\n') # Truncated for brevity
# … The rest of the article card HTML
file.write(' </div>\n')
file.write('</div>\n') # Close the article cards container
file.write('</div>\n') # Close the primary container
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>')
Assuming you have a JSON file with article data saved at filename_json
filename_json = "list_file_html.json"
with open(filename_json, "r") as file_json:
articles_data = json.load(file_json)
Create article information based on the JSON data
Make sure each 'article' is a dictionary before using 'get' method
articles_info = [
{
"filepath": article.get('filepath', '#') if isinstance(article, dict) else '#',
"title": article.get('title', 'Title Unavailable') if isinstance(article, dict) else 'Title Unavailable',
"thumbnail": article.get('thumbnail', 'default_thumbnail.png') if isinstance(article, dict) else 'default_thumbnail.png',
"description": article.get('description', 'No description provided.') if isinstance(article, dict) else 'No description provided.'
}
for article in articles_data
]
HTML header template, possibly including links to CSS files, etc.
html_template_header = (
"\n"
"\n"
)
Create the index HTML with the article information
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.") BUATKAN FULL NYAA
import os
import json
from datetime import datetime
import random
# ... (the rest of your original functions for content creation) ...
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# HTML boilerplate
file.write('<!DOCTYPE html>\n')
file.write('<html lang="en">\n')
file.write('<head>\n')
file.write(' <meta charset="UTF-8">\n')
file.write(' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n')
file.write(' <meta http-equiv="X-UA-Compatible" content="ie=edge">\n')
file.write(' <meta name="description" content="A collection of articles">\n')
file.write(' <title>Your Website Title Here</title>\n')
# Add any other SEO tags or links to stylesheets here
file.write(template) # Adding the template header to the HTML file
file.write('</head>\n')
file.write('<body>\n')
# Article cards section
file.write('<div class="container">\n')
file.write('<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">\n') # Use a more specific grid layout
# Iterate over `articles_info` to create HTML cards for each article
for i, article in enumerate(articles_info, 1):
# Assuming `article` is a file path, we need to extract relevant info for each card
title = f"Article {i}" # Some placeholder title
thumbnail = "default_thumbnail.png" # Some default thumbnail image path
# Each article card
file.write(f'<div class="mx-3 mt-6 flex flex-col rounded-lg bg-white shadow-lg">\n')
file.write(f' <a href="{article}">\n')
file.write(f' <img class="rounded-t-lg" src="{thumbnail}" alt="{title}">\n')
file.write(f' </a>\n')
file.write(f' <div class="p-6">\n')
file.write(f' <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{title}</h5>\n')
file.write(f' <p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Description of article {i}.</p>\n')
file.write(f' </div>\n')
file.write(f'</div>\n')
# Close the article cards container and the primary container
file.write('</div>\n')
file.write('</div>\n')
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>')
# ... (load 'list_file_html.json' and call create_index_html function as before) ...
In the create_index_html function, I've corrected the div class for the grid layout and assumed that each article in JSON is just a filename path, as your code suggests. You should replace the placeholder title, thumbnail, and description with actual content.
Please note that the code snippet above is here to guide you in further developing your script based on the components provided. It may require additional tweaking and inclusion of actual file paths and content to fully integrate into your project.
<header class="max-w-xl mx-auto mt-10 text-center">
<h1 class="text-4xl font-bold">{judul}</h1>
<p class="mt-2 text-sm text-gray-600">{deskripsi}</p>
</header>
<main class="max-w-xl mx-auto my-10 bg-white p-8 rounded-lg shadow-md">
<article>
<section class="my-5">
<h2 class="text-2xl font-semibold">Permainan Togel Hongkong</h2>
<p class="mt-4">Permainan Togel Hongkong menjadi salah satu hiburan populer di Indonesia. Sukses memenangkan permainan ini membutuhkan prediksi yang akurat dan terpercaya. Prediksi kami yang jitu akan meningkatkan peluang kemenangan Anda dalam permainan Togel Hongkong.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Bocoran Prediksi Togel HKG-Hongkong Terjitu</h2>
<p class="mt-4">Dalam artikel ini, Kubet akan memberikan wawasan mengenai pentingnya prediksi togel yang akurat dan terpercaya. Kami memberikan bocoran angka yang disusun dengan strategi teruji, sumber terpercaya, dan kerja sama para ahli yang berpengalaman dalam prediksi togel.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Prediksi Hongkong Hari Ini</h2>
<p class="mt-4">Prediksi Hongkong akan diperbarui setiap hari sebelum pukul 22.00 WIB. Meskipun kami menggunakan sumber dan ahli yang terpercaya, prediksi ini hanya sebagai peluang kemenangan dan tidak dijamin pasti.</p>
<!-- Tabel Prediksi -->
<div class="overflow-x-auto mt-6">
<table class="min-w-full bg-gradient-to-r from-red-700 to-red-700 border border-red-700 divide-y divide-red-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Kategori </th>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Prediksi </th>
</tr>
</thead>
<tbody>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">BBFS (Bolak-Balik Full Set)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["BBFS"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">AM (Angka Main)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["AM"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">4D TOP</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["4D TOP"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">2D TOP BB</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["2D TOP BB"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">COLOK BEBAS</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["COLOK BEBAS"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> TWIN</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(map(str, prediksi["TWIN"]))}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> SHIO</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(prediksi["SHIO"])}</td>
</tr>
</tbody>
</table>
</div>
<p class="mt-6 italic">Prediksi digunakan dengan pertimbangan sumber-sumber terpercaya dan kerjasama dengan para ahli. Prediksi ini hanya sebagai peluang kemenangan.</p>
</section>
</article>
</main>
<footer class="max-w-xl mx-auto my-6 text-center">
<p class="text-sm">Terima kasih telah mempercayai kubet sebagai sumber prediksi togel Hongkong Anda. Kami harap prediksi kami membantu dalam memilih angka yang tepat. Selamat bermain dan semoga beruntung!</p>
<p class="text-gray-600 text-sm mt-2">kubet Indonesia</p>
</footer>
<!-- Tailwind UI -->
<script src="https://cdn.tailwindcss.com"></script>
Generate random predictions
prediksi_acak = generate_random_predictions()
Dapatkan tanggal pembuatan untuk judul artikel
tanggal_pembuatan = get_current_date()
Ganti hanya bagian tertentu dengan hasil dari generate_random_predictions()
filename_html = f"prediksi_togel_hongkong_{tanggal_pembuatan}.html"
with open(filename_html, "w") as file_html:
file_html.write(html_artikel)
Tambahkan file HTML yang baru dibuat ke dalam list_file_html
list_file_html.append(filename_html)
Simpan list file HTML ke dalam file JSON
filename_json = "list_file_html.json"
with open(filename_json, "w") as file_json:
json.dump(list_file_html, file_json)
print(f"Artikel berhasil disimpan dalam file {filename_html}")
print(f"List file HTML berhasil disimpan dalam file {filename_json}")
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# HTML boilerplate
file.write('\n')
file.write('\n')
file.write('\n')
file.write(' \n')
file.write(' \n')
file.write(' \n')
file.write(' \n')
file.write(' Your Website Title Here\n')
file.write('\n')
# Add any other SEO tags or links to stylesheets here
file.write(template) # Adding the template header to the HTML file
file.write('\n')
file.write('\n')
code
# Article cards section
file.write('<div class="container">\n')
file.write('<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">\n') # Use a more specific grid layout
# Iterate over articles_info to create HTML cards for each article
for i, article in enumerate(articles_info, 1):
# Assuming article is a file path, we need to extract relevant info for each card
title = f"Article {i}" # Some placeholder title
thumbnail = "default_thumbnail.png" # Some default thumbnail image path
# Each article card
file.write(f'<div class="mx-3 mt-6 flex flex-col rounded-lg bg-white shadow-lg">\n')
file.write(f' <a href="{article}">\n')
file.write(f' <img class="rounded-t-lg" src="{thumbnail}" alt="{title}">\n')
file.write(f' </a>\n')
file.write(f' <div class="p-6">\n')
file.write(f' <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{title}</h5>\n')
file.write(f' <p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Description of article {i}.</p>\n')
file.write(f' </div>\n')
file.write(f'</div>\n')
# Close the article cards container and the primary container
file.write('</div>\n')
file.write('</div>\n')
file.write('<script src="https://cdn.tailwindcss.com"></script>\n')
# Closing tags for body and html
file.write('</body>\n')
file.write('</html>')
Assuming you have a JSON file with article data saved at filename_json
filename_json = "list_file_html.json"
with open(filename_json, "r") as file_json:
articles_data = json.load(file_json)
Create article information based on the JSON data
Make sure each 'article' is a dictionary before using 'get' method
articles_info = [
{
"filepath": article.get('filepath', '#') if isinstance(article, dict) else '#',
"title": article.get('title', 'Title Unavailable') if isinstance(article, dict) else 'Title Unavailable',
"thumbnail": article.get('thumbnail', 'default_thumbnail.png') if isinstance(article, dict) else 'default_thumbnail.png',
"description": article.get('description', 'No description provided.') if isinstance(article, dict) else 'No description provided.'
}
for article in articles_data
]
HTML header template, possibly including links to CSS files, etc.
html_template_header = (
"\n"
"\n"
)
Create the index HTML with the article information
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.") buat semu index dan artikel agar saling bersambung
# ...
def create_index_html(template, articles_info, output_file="indeks_artikel.html"):
with open(output_file, "w") as file:
# ... Your existing code to write the beginning of the HTML file ...
# Article cards section
file.write('<div class="container mx-auto mt-8">\n')
file.write('<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">\n')
# Iterate over articles_info to create HTML cards for each article
for article in articles_info:
filepath = article['filepath']
title = article['title']
thumbnail = article['thumbnail']
description = article['description']
# Each article card
file.write('<div class="mx-3 my-6 flex flex-col rounded-lg bg-white shadow-lg">\n')
file.write(f' <a href="{filepath}" class="hover:opacity-75">\n')
file.write(f' <img class="rounded-t-lg" src="{thumbnail}" alt="{title}">\n')
file.write(f' </a>\n')
file.write(f' <div class="p-6">\n')
file.write(f' <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900">{title}</h5>\n')
file.write(f' <p class="font-normal text-gray-700">{description}</p>\n')
file.write(f' </div>\n')
file.write('</div>\n')
file.write('</div>\n')
file.write('</div>\n')
# ... Your existing code to include Tailwind CSS script and write the end of the HTML file ...
# ...
# Generate random predictions and create an article HTML
prediksi_acak = generate_random_predictions()
tanggal_pembuatan = get_current_date()
html_artikel = buat_html_artikel(tanggal_pembuatan, prediksi_acak)
# Save article HTML to a file and add this file to list_file_html
filename_html = f"prediksi_togel_hongkong_{tanggal_pembuatan}.html"
with open(filename_html, "w") as file_html:
file_html.write(html_artikel)
list_file_html.append({
"filepath": filename_html,
"title": f"Bocoran Prediksi Togel Hongkong Hari Ini {tanggal_pembuatan}",
"thumbnail": "thumbnail_path.jpg", # Replace with the actual thumbnail path
"description": "Deskripsi singkat artikel anda di sini." # Replace with the actual description
})
# Save list_file_html to a JSON file
with open("list_file_html.json", "w") as file_json:
json.dump(list_file_html, file_json)
# Read list_file_html from the JSON file
with open("list_file_html.json", "r") as file_json:
articles_info = json.load(file_json)
# Create the index HTML with the article information
create_index_html(html_template_header, articles_info)
print("Indeks artikel HTML telah berhasil dibuat dengan SEO penuh.")
This updated script includes the creation of an index HTML that lists all the articles with clickable titles, images, and descriptions that link to the individual article HTML pages.
Ensure that when you generate a new article HTML, you also add its information as a dictionary to the list_file_html array. The dictionary must contain the keys: 'filepath', 'title', 'thumbnail', and 'description'. This will ensure that the index page can utilize this data to create links to the articles.
Also, replace "thumbnail_path.jpg" with the actual path to the thumbnail image for each article, and update the article description to the real description you want to showcase on the index page.
Be aware that I've added output_folder to hold the output HTML files, and I've created create_navbar and create_footer helper functions to generate consistent navigational headers and footers for both the article and index pages.
Remember to replace placeholder paths and text with actual content, and ensure that output_folder exists before running this code. The structure and optimization of the HTML can be further refined based on your needs and content.
This script generates styled article and index pages with Tailwind CSS. It's comprehensive in that it:
Creates individual article pages with styling.
Generates an index page linking to each article.
Uses helper functions for reusability and cleaner code.
Ensures output directory existence before saving files.
Run this entire script as-is, after ensuring you have an 'output' directory in your project folder. You can further customize the generated HTML files by adding more Tailwind CSS classes, your content, and any other specific features you'd like to include.
<article>
<section class="my-5">
<h2 class="text-2xl font-semibold">Permainan Togel Hongkong</h2>
<p class="mt-4">Permainan Togel Hongkong menjadi salah satu hiburan populer di Indonesia. Sukses memenangkan permainan ini membutuhkan prediksi yang akurat dan terpercaya. Prediksi kami yang jitu akan meningkatkan peluang kemenangan Anda dalam permainan Togel Hongkong.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Bocoran Prediksi Togel HKG-Hongkong Terjitu</h2>
<p class="mt-4">Dalam artikel ini, Kubet akan memberikan wawasan mengenai pentingnya prediksi togel yang akurat dan terpercaya. Kami memberikan bocoran angka yang disusun dengan strategi teruji, sumber terpercaya, dan kerja sama para ahli yang berpengalaman dalam prediksi togel.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Prediksi Hongkong Hari Ini</h2>
<p class="mt-4">Prediksi Hongkong akan diperbarui setiap hari sebelum pukul 22.00 WIB. Meskipun kami menggunakan sumber dan ahli yang terpercaya, prediksi ini hanya sebagai peluang kemenangan dan tidak dijamin pasti.</p>
<!-- Tabel Prediksi -->
<div class="overflow-x-auto mt-6">
<table class="min-w-full bg-gradient-to-r from-red-700 to-red-700 border border-red-700 divide-y divide-red-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Kategori </th>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Prediksi </th>
</tr>
</thead>
<tbody>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">BBFS (Bolak-Balik Full Set)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">5161473</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">AM (Angka Main)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">56114</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">4D TOP</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">4671, 7514, 5137, 3716</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">2D TOP BB</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">51, 41, 45, 31, 76, 14, 71, 47, 71, 61</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">COLOK BEBAS</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">5, 4, 7</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> TWIN</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> 11, 44, 55, 11</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> SHIO</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> Kelinci, Naga, Kerbau</td>
</tr>
</tbody>
</table>
</div>
<p class="mt-6 italic">Prediksi digunakan dengan pertimbangan sumber-sumber terpercaya dan kerjasama dengan para ahli. Prediksi ini hanya sebagai peluang kemenangan.</p>
</section>
</article>
</main>
Make sure to:
Replace http://example.com/path/to/article with the actual URL where your article will be hosted.
Update http://example.com/path/to/image.jpg with the URL to the image that best represents your article.
Use the canonical link to point to the primary version of the content to avoid duplicate content issues for SEO.
The <meta> tags provide information about the webpage for search engines and social platforms. The Open Graph protocol helps your page to become a rich object in a social graph, primarily used by Facebook, while Twitter Cards do a similar force for Twitter. The canonical link helps avoid SEO issues related to duplicate content.
By including these elements, you have increased the SEO potential of your article page, which could lead to better visibility on search engines and social media platforms.
<article>
<section class="my-5">
<h2 class="text-2xl font-semibold">Permainan Togel Hongkong</h2>
<p class="mt-4">Permainan Togel Hongkong menjadi salah satu hiburan populer di Indonesia. Sukses memenangkan permainan ini membutuhkan prediksi yang akurat dan terpercaya. Prediksi kami yang jitu akan meningkatkan peluang kemenangan Anda dalam permainan Togel Hongkong.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Bocoran Prediksi Togel HKG-Hongkong Terjitu</h2>
<p class="mt-4">Dalam artikel ini, Kubet akan memberikan wawasan mengenai pentingnya prediksi togel yang akurat dan terpercaya. Kami memberikan bocoran angka yang disusun dengan strategi teruji, sumber terpercaya, dan kerja sama para ahli yang berpengalaman dalam prediksi togel.</p>
</section>
<section class="my-5">
<h2 class="text-2xl font-semibold">Prediksi Hongkong Hari Ini</h2>
<p class="mt-4">Prediksi Hongkong akan diperbarui setiap hari sebelum pukul 22.00 WIB. Meskipun kami menggunakan sumber dan ahli yang terpercaya, prediksi ini hanya sebagai peluang kemenangan dan tidak dijamin pasti.</p>
<!-- Tabel Prediksi -->
<div class="overflow-x-auto mt-6">
<table class="min-w-full bg-gradient-to-r from-red-700 to-red-700 border border-red-700 divide-y divide-red-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Kategori </th>
<th class="px-6 py-3 text-left text-xs font-semibold text-white uppercase bg-gradient-to-r "> Prediksi </th>
</tr>
</thead>
<tbody>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">BBFS (Bolak-Balik Full Set)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["BBFS"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">AM (Angka Main)</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{prediksi["AM"]}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">4D TOP</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["4D TOP"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">2D TOP BB</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["2D TOP BB"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300">COLOK BEBAS</td>
<td class="px-6 py-4 text-sm border-b border-gray-300">{", ".join(prediksi["COLOK BEBAS"])}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> TWIN</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(map(str, prediksi["TWIN"]))}</td>
</tr>
<tr class="bg-gradient-to-r from-blue-50 to-purple-50">
<td class="px-6 py-4 text-sm border-b border-gray-300"> SHIO</td>
<td class="px-6 py-4 text-sm border-b border-gray-300"> {", ".join(prediksi["SHIO"])}</td>
</tr>
</tbody>
</table>
</div>
<p class="mt-6 italic">Prediksi digunakan dengan pertimbangan sumber-sumber terpercaya dan kerjasama dengan para ahli. Prediksi ini hanya sebagai peluang kemenangan.</p>
</section>
</article>
</main>
{create_footer()}
In the function above:
Replace "URL_TO_IMAGE" with the actual image URL you want to use for Open Graph and Twitter Cards. This image is typically used when the page is shared on social media.
Replace "URL_TO_ARTICLE" with the actual URL where the article will be published.
Additional SEO keywords are provided in a meta tag. These should be relevant to the content of the article for better search engine indexing.
With these changes, the article page will have enhanced metadata that can improve visibility in search engine results and when shared on social media platforms.