Welcome to DIY schema.org, a lightweight software tool for defining your own classes and properties based on the schema.org vocabulary. This software allows you to create custom schemas while reusing properties and classes already available via schema.org.
DIY schema.org is a simplified version of the software used to build schema.org. It has been streamlined for ease of use and focuses on enabling users to define their own schemas quickly and efficiently. All tests have been removed along with most of the functionality for attic, proposed, and extension namespaces. It is intended for simple schema creation tasks.
To use DIY schema.org, follow these steps:
-
Download: Download the software package.
-
Do a build:
- Run
./software/util/buildsite.py -a
to build the site.
- Run
-
Run the Server:
- Execute
./software/server.py
to run the server.
- Execute
-
View the output:
- Once the server is running, you can view the site at http://localhost:8080.
-
Change the URI base:
- Open
software/SchemaTerms/sdotermsource.py
and setDEFVOCABURI
to your base URI (e.g.,https://example.com
). - Open
docs/pretty-markup/layout.js
and setVOCAB_URI
to your base URI (e.g.,var VOCAB_URI = 'https://example.com';
). - Open
software/server.py
and setVOCAB_URI
to your base URI (e.g.,var VOCAB_URI = 'https://example.com';
).
- Open
-
Define your own schema and examples:
- Edit the files in the
data
directory to specify your schema and examples.
- Edit the files in the
-
GOTO (2)
The python devserver has been renamed server.py and now supports content negotiation, allowing you to request different representations of the data based on the Accept
header sent with the request. To use content negotiation:
- Include the
Accept
header in your HTTP request with the desired content type. Supported content types includetext/html
,application/rdf+xml
,text/turtle
andapplication/ld+json
. - The server will respond with the requested representation of the data based on the provided content type.
For example, to request RDF/XML representation of a resource, you can use the following command:
curl -H "Accept: application/rdf+xml" http://localhost:8080/<resource_path>
Before installing DIY schema.org, ensure that you have Python 3.10 or above installed on your system.
It is recommended to create a Python virtual environment to avoid conflicts with other Python activities on your system. For instructions on how to create virtual environments, refer to the Python documentation.
DIY schema.org depends on a small number of Python libraries. To install these dependencies, run the following command in the root directory of the schemaorg repository:
pip install -r software/requirements.txt
All commands and scripts should be executed from the root schemaorg directory.
If you encounter a "ModuleNotFoundError: No module named 'module_name'" error when running local scripts, it may be due to:
- Your Python environment not being correctly set to 3.10 or above.
- Missing required modules due to new dependencies or changes.
To ensure you have the correct modules installed, re-run the command:
pip install -r software/requirements.txt
After cloning the repository and setting up the Python environment, run the following command for the initial build:
./software/util/buildsite.py -a
This command creates a local working copy of the schema.org website in the site directory.
The buildsite.py
script is responsible for creating and managing a local image website as a set of static HTML pages and downloadable files in the site directory. It constructs this from local working copies of the files in the repository. The contents of the site directory are not committed and stored in the repository. The site directory image serves two main purposes:
- It provides a local work-in-progress representation of the website for local testing and debugging.
- It provides an image of the website that can be deployed.
After running the initial build, you can further customize your schema and examples before deploying or testing locally.
We welcome feedback and contributions to DIY schema.org. If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
Happy schema designing!